public function getById($id)
 {
     $sql = "select genre from mvc_genres where id = :id";
     $dbh = new PDO(DBConfig::$DB_CONNSTRING, DBConfig::$DB_USERNAME, DBConfig::$DB_PASSWORD);
     $stmt = $dbh->prepare($sql);
     $stmt->execute(array(':id' => $id));
     $rij = $stmt->fetch(PDO::FETCH_ASSOC);
     $genre = Genre::create($id, $rij["genre"]);
     $dbh = null;
     return $genre;
 }
Exemple #2
0
 public function getAll()
 {
     $sql = "select id, genre from mvc_genres";
     $dbh = new PDO(DBConfig::$DB_CONNSTRING, DBConfig::$DB_USERNAME, DBConfig::$DB_PASSWORD);
     $resultSet = $dbh->query($sql);
     $lijst = array();
     foreach ($resultSet as $rij) {
         $genre = Genre::create($rij["id"], $rij["genre"]);
         array_push($lijst, $genre);
     }
     $dbh = null;
     return $lijst;
 }
Exemple #3
0
 public function getAll()
 {
     $sql = "select mvc_boeken.id as boek_id, titel, genre_id, genre from mvc_boeken,  \n            mvc_genres where genre_id = mvc_genres.id";
     $dbh = new PDO(DBConfig::$DB_CONNSTRING, DBConfig::$DB_USERNAME, DBConfig::$DB_PASSWORD);
     $resultSet = $dbh->query($sql);
     $lijst = array();
     foreach ($resultSet as $rij) {
         $genre = Genre::create($rij["genre_id"], $rij["genre"]);
         $boek = Boek::create($rij["boek_id"], $rij["titel"], $genre);
         array_push($lijst, $boek);
     }
     $dbh = null;
     return $lijst;
 }
 public function getByTitel($titel)
 {
     $sql = "select mvc_boeken.id as boek_id, titel, genre_id, genre from mvc_boeken, mvc_genres where titel = :titel";
     $dbh = new PDO(DBConfig::$DB_CONNSTRING, DBConfig::$DB_USERNAME, DBConfig::$DB_PASSWORD);
     $stmt = $dbh->prepare($sql);
     $stmt->execute(array(':titel' => $titel));
     $rij = $stmt->fetch(PDO::FETCH_ASSOC);
     if (!$rij) {
         return null;
     } else {
         $genre = Genre::create($rij["genre_id"], $rij["genre"]);
         $boek = Boek::create($rij["boek_id"], $titel, $rij["genre"]);
         $dbh = null;
         return $boek;
     }
 }