Call to a member function fetch() on a non-object
Salut ! J'ai besoin d'aide svp. J'ai une fonction:
Code:
1 2 3 4 5 6 7 8 9 10 11 12
|
public function getAll() {
$pharmas = array();
$query = $this->_db->exec('SELECT * FROM pharmacies');
while ($data = $query->fetch(PDO::FETCH_ASSOC)) {
$pharmas[] = new Pharmacy($data);
}
return $pharmas;
} |
Quand je l'appelle:
Code:
$pharmas = $manager->getAll();
J'ai une erreur du type:
Citation:
Fatal error: Call to a member function fetch() on a non-object
Voici l'objet _db
Code:
1 2 3
|
$db = new PDO('mysql:host=localhost;dbname=pharma', 'root', '');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
J'ai besoin d'aide la communauté. Merci !!!