2
I am having trouble trying to rescue one or a list of images that I have already inserted in mysql 5 with PDO. I have a dao class that 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 view.
my bank entity is as follows.
in the browser is showing as follows.
Related: http://answall.com/questions/48325/slideshow-com-imagens-blob-do-mysql/
– rray