Esempio n. 1
0
 public static function addAddress($street, $zipcode, $city, $latitude, $longitude)
 {
     $db = DbManager::getPDO();
     $query = "INSERT INTO Address(street, zipcode, city, latitude, longitude)\n              VALUES ('" . $street . "'," . intval($zipcode) . ",'" . $city . "','" . $latitude . "','" . $longitude . "')";
     $db->exec($query);
     $query = "SELECT idAddress FROM Address WHERE street = '" . $street . "' AND zipcode = " . intval($zipcode) . " AND city = '" . $city . "';";
     $res = $db->query($query)->fetch();
     return $res['idAddress'];
 }
Esempio n. 2
0
 public static function addOpinionInDataBase($stars, $description, $idUser, $idShelter)
 {
     if (Shelter::isShelterExistInDataBase($idShelter)) {
         $db = DbManager::getPDO();
         $query = "INSERT INTO Opinion(stars, description, idUser, idShelter) " . "VALUES (" . $stars . ", '" . $description . "'," . $idUser . "," . $idShelter . ")";
         return $db->exec($query) >= 0;
     } else {
         return "Unknown shelter";
     }
 }
Esempio n. 3
0
 /**
  * @return la liste des animaux à l'adoption
  */
 public static function getHomelessAnimals()
 {
     $db = DbManager::getPDO();
     $query = "SELECT * FROM Animal WHERE idState='" . self::$STATE_ADOPTION . "';";
     $res = $db->query($query)->fetchAll();
     for ($i = 0; $i < count($res); $i++) {
         $animal = Animal::getAnimalArrayFromFetch($res[$i]);
         $listAnimals[$animal['idAnimal']] = $animal;
     }
     return $listAnimals;
 }
Esempio n. 4
0
 public function getAnimals()
 {
     $db = DbManager::getPDO();
     $req = "SELECT * FROM Animal an, Adopt ad WHERE an.idAnimal=ad.idAnimal AND ad.idUser="******"";
     $res = $db->query($query);
     for ($i = 0; $i < count($res); $i++) {
         $animal = Animal::getAnimalArrayFromFetch($res[$i]);
         $listUsersAnimals[$animal['idAnimal']] = $animal;
     }
     return $listUsersAnimals;
 }
Esempio n. 5
0
 public function getOpinions()
 {
     $db = DbManager::getPDO();
     $query = "SELECT * FROM Opinion WHERE idShelter = " . $this->idShelter . ";";
     $res = $db->query($query)->fetchAll();
     for ($i = 0; $i < count($res); $i++) {
         $opinion = Opinion::getOpinionArrayFromFetch($res[$i]);
         $listOpinions[$opinion['idOpinion']] = $opinion;
     }
     return $listOpinions;
 }