I'm having trouble trying to retrieve one or a list of images that I've already inserted into mysql 5 with PDO. I have a class of what has the architecture of my querys to work with the database.
class ImagemDao {
public function inserirImagem(ImagemEntity $imagem) {
$conexao = ...
$stmt = $conexao->getStance()->prepare("INSERT INTO imagem(imagem,id_pagina) VALUES(:img, :idPagina)");
$stmt->bindValue(":img", $imagem->getImagem());
$stmt->bindValue(":idPagina", $imagem->getIdPagina());
$stmt->execute();
}
public function selecionaTodasImagens() {
$conexao = ...
$consulta = $conexao->getStance()->query("SELECT id_imagem, imagem, id_pagina FROM imagem;");
while ($linha = $consulta->fetch(PDO::FETCH_OBJ)){
echo $linha->id_imagem ."</br>" ;
echo $linha->imagem ."</br>";
echo $linha->id_pagina ."</br>";
}
}
My bean is as follows.
class ImagemEntity {
private $id;
private $imagem;
private $idPagina;
function __construct($id = "", $imagem = "", $idPagina = "") {
$this->id = $id;
$this->imagem = $imagem;
$this->idPagina = $idPagina;
}
//get and set
and I have a test file
<?php
$dao = new ImagemDao();
$dao->selecionaTodasImagens();
?>
What it returns to me are just the text of the image and its id but no display.
My bank entity is as follows.
in the browser is showing as follows.