/** * Récupère x films au hazard depuis la table movies */ public function getRandomMovies() { $dbConnector = new DatabaseConnector(); $dbh = $dbConnector->getDbh(); $sql = "SELECT id, title, year, imdb_id\n\t\t\t\t\tFROM movies\n\t\t\t\t\tORDER BY RAND()\n\t\t\t\t\tLIMIT 30"; $sth = $dbh->prepare($sql); $sth->execute(); $movies = $sth->fetchAll(); return $movies; }
public function getRandomBd() { $dbConnector = new DatabaseConnector(); $dbh = $dbConnector->getDbh(); $sql = "SELECT id, illustrator, scenarist, colorist, cover\n\t\tFROM books\n\t\tORDER BY RAND()\n\t\tLIMIT 20"; $sth = $dbh->prepare($sql); $sth->execute(); $movies = $sth->fetchAll(); return $books; }
public function find($id) { $dbConnector = new DatabaseConnector(); $dbh = $dbConnector->getDbh(); $sql = "SELECT *\n\t\t\t\t\tFROM {$this->table}\n\t\t\t\t\tWHERE id = :id"; $sth = $dbh->prepare($sql); $sth->bindValue(":id", $id); $sth->execute(); $row = $sth->fetch(); return $row; }