I'm trying make a query in SQL in order to get some data, but my
fetchAll() isn't working.
I'm trying to return the result of the query in the end of the function, but i got the error : Fatal error: Uncaught Error: Call to a member function fetchAll() on boolean
.
My connection with database works fine in every test, so i know that file may be okay, it seems it's some problem in the query function that i's in other file.
Here's my file funcoes_db.php:
require_once("conecta_db.php");
$db = new Db();
$con = $db->conexao;
/* Class Declaration */
class FuncoesDb{
function listaSlides(){
global $con;
$where = "";
$sql = "SELECT imgsld.img_nome, imgsld.legenda FROM slid_imgs imgsld";
$obj = $con->prepare($sql." ".$where);
$imagens = $obj->execute();
$imgs = $imagens->fetchAll(PDO::FETCH_ASSOC);
return $imgs;
}
And how i'm trying to get the returned value in my index.php:
require_once("funcoes/funcoes_db.php");
$func = new FuncoesDb();
$imgs = $func->listaSlides();