本文整理匯總了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;
}