本文整理汇总了PHP中DbManager::getPDO方法的典型用法代码示例。如果您正苦于以下问题:PHP DbManager::getPDO方法的具体用法?PHP DbManager::getPDO怎么用?PHP DbManager::getPDO使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DbManager
的用法示例。
在下文中一共展示了DbManager::getPDO方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addAddress
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'];
}
示例2: addOpinionInDataBase
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";
}
}
示例3: getHomelessAnimals
/**
* @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;
}
示例4: getAnimals
public function getAnimals()
{
$db = DbManager::getPDO();
$req = "SELECT * FROM Animal an, Adopt ad WHERE an.idAnimal=ad.idAnimal AND ad.idUser=" . $this->idUser . "";
$res = $db->query($query);
for ($i = 0; $i < count($res); $i++) {
$animal = Animal::getAnimalArrayFromFetch($res[$i]);
$listUsersAnimals[$animal['idAnimal']] = $animal;
}
return $listUsersAnimals;
}
示例5: getOpinions
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;
}