diff --git a/class/objet.php b/class/objet.php index 767a4ecbf17896cf48b0afe0f1112e1eba412c50..72cf49f5adb92b5d0486e4204a9590ab8e18c0cc 100644 --- a/class/objet.php +++ b/class/objet.php @@ -14,7 +14,18 @@ class Objet public static function getAll() { // TODO return list of objects Client - echo "toto:".get_called_class(); - return Array(); + $dbName = lcfirst(get_called_class()); + $bdd = new Db(); + $result = Array(); + + $requete_prepare = $bdd->db->prepare("SELECT * FROM :table"); // on prépare notre requête + $requete_prepare->execute(array( 'table' => $dbName )); + while($ligne = $requete_prepare->fetch(PDO::FETCH_ASSOC)) { + $temp = new get_called_class()(); + $temp->fromDb($ligne); + $result[] = $temp; + } + + return $result; } } \ No newline at end of file