當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DbManager::getPDO方法代碼示例

本文整理匯總了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'];
 }
開發者ID:Gouga34,項目名稱:Server,代碼行數:9,代碼來源:Address.php

示例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";
     }
 }
開發者ID:Gouga34,項目名稱:Server,代碼行數:10,代碼來源:Opinion.php

示例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;
 }
開發者ID:Gouga34,項目名稱:Server,代碼行數:14,代碼來源:Animal.php

示例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;
 }
開發者ID:Gouga34,項目名稱:Server,代碼行數:11,代碼來源:User.php

示例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;
 }
開發者ID:Gouga34,項目名稱:Server,代碼行數:11,代碼來源:Shelter.php


注:本文中的DbManager::getPDO方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。