1
I want to store all the records of my tables within a session
, when I call my records it only pulls 1 result
class CRUD extends Config {
private $query;
private function prepExec($prep, $exec) {
$this->query = $this->getConn()->prepare($prep);
$this->query->execute($exec);
}
public function select($fields, $table, $prep, $exec) {
$this->prepExec("SELECT ".$fields." FROM ".$table." ".$prep."", $exec);
return $this->query;
}
}
tried so
index php.
session_start();
$not = $crd->select('*', 'noticias', 'ORDER BY id DESC', array());
foreach ($not as $reg) :
$_SESSION['slug_noticia'] = $not['slug_noticia'];
$_SESSION['nome_noticia'] = $not['nome_noticia'];
endforeach;
and so
$not = $crd->select('*', 'noticias', 'ORDER BY id DESC', array());
foreach ($not as $reg) :
$_SESSION['reg'] = $reg;
endforeach;
man because?
Cannot use object of type PDOStatement as array
along those lines$_SESSION['noticias'][$not['id']] = $not;
– goio
@Mayron debugging is life... If you’re returning this, it’s because you didn’t turn the
fetch
ofPDOStatment
somewhere.– Wallace Maxters