Beispiel #1
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";
     }
 }
Beispiel #2
0
 public static function getAllShelters()
 {
     $db = DbManager::getPDO();
     $query = "SELECT * FROM Shelter;";
     $res = $db->query($query)->fetchAll();
     for ($i = 0; $i < count($res); $i++) {
         $shelter = Shelter::getShelterArrayFromFetch($res[$i]);
         $listShelters[$shelter['idShelter']] = $shelter;
     }
     return $listShelters;
 }
<?php

require_once 'models/Opinion.php';
$shelter = new Shelter($_POST['idShelter']);
$listOpinions = $shelter->getOpinions();
echo json_encode($listOpinions);
Beispiel #4
0
<?php

require_once 'models/Shelter.php';
$shelter = new Shelter($_POST['idShelter']);
$addResult = $shelter->addAnimal($_POST['idAnimal']);
if (gettype($addResult) === "string") {
    $response = ['success' => false, 'error' => $addResult];
} else {
    $response = ['success' => $addResult];
}
echo json_encode($response);
Beispiel #5
0
<?php

require_once 'models/Shelter.php';
$shelter = new Shelter($_POST['idShelter']);
$listAnimals = $shelter->getAnimals();
echo json_encode($listAnimals);
Beispiel #6
0
 public function followShelter($idShelter)
 {
     if (Shelter::isShelterExistInDataBase($idShelter)) {
         $db = DbManager::getPDO();
         $query = "INSERT INTO FollowShelter(idUser, idShelter) VALUES (" . $this->idUser . "," . $idShelter . ")";
         return $db->exec($query) >= 0;
     } else {
         return "Unknown shelter";
     }
 }
Beispiel #7
0
<?php

require_once 'models/Shelter.php';
$addResult = Shelter::addShelterInDataBase($_POST['name'], $_POST['phone'], $_POST['description'], $_POST['email'], $_POST['operationalHours'], $_POST['street'], $_POST['zipcode'], $_POST['city'], $_POST['latitude'], $_POST['longitude']);
echo json_encode(['success' => $addResult]);
Beispiel #8
0
<?php

require_once 'models/Shelter.php';
$shelter = new Shelter($_POST['idShelter']);
$user = new User($_POST['nickname']);
$result = $shelter->addManager($user->getId());
echo json_encode(["success" => $result]);
<?php

require_once 'models/Shelter.php';
$shelter = new Shelter($_POST['idShelter']);
$user = new User($_POST['nickname']);
$result = $shelter->addAdministrator($user->getId());
echo json_encode(["success" => $result]);
Beispiel #10
0
<?php

require_once 'models/Shelter.php';
$listShelters = Shelter::getAllShelters();
echo json_encode($listShelters);