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


PHP PDO::Prepare方法代碼示例

本文整理匯總了PHP中PDO::Prepare方法的典型用法代碼示例。如果您正苦於以下問題:PHP PDO::Prepare方法的具體用法?PHP PDO::Prepare怎麽用?PHP PDO::Prepare使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PDO的用法示例。


在下文中一共展示了PDO::Prepare方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: Query_Prepare

 /**
  * The SQL Query preparation combined with Query_Execute
  *
  * @version 1
  * @author Rick de Man <rick@rickdeman.nl>
  *        
  * @param string $Query
  *        	The Query to be executed
  * @param string $Comment
  *        	The Comment for the Query, for Debug use
  */
 public function Query_Prepare($Query, $Comment)
 {
     // The SQL must be free to continue
     if ($this->SQL_Free !== true) {
         $this->Query_Next();
     }
     // SQL is occupied
     $this->SQL_Free = false;
     // Replace Table tag
     $Query = $this->Query_Table_Preg($Query);
     // Prepare the Query
     $this->STH = $this->DBH->Prepare($Query);
     // Load the Backtrace
     $Trace = debug_backtrace();
     // Create a SQL Log Event
     $this->Log = array('F' => $Trace[0]['file'] . ':' . $Trace[0]['line'] . '(' . $Trace[1]['function'] . ')', 'Q' => $Query, 'P' => array(), 'C' => $Comment);
 }
開發者ID:RickdeM,項目名稱:wms,代碼行數:28,代碼來源:sql.php

示例2: update

 /**
  * updates this Crew in mySQL
  *
  * @param \PDO $pdo PDO connection object
  * @throws \PDOException when mySQL related errors occur
  * @throws \TypeError if $pdo is not a PDO connection object
  **/
 public function update(\PDO $pdo)
 {
     //enforce the crewID is not null (i.e., don't update a crew that hasn't been inserted)
     if ($this->crewId === null) {
         throw new \PDOException("unable to update a crew that does not exist");
     }
     //create query template
     $query = "UPDATE crew SET crewCompanyId = :crewCompanyId, crewLocation = :crewLocation  WHERE crewId = :crewId";
     $statement = $pdo->Prepare($query);
     //bind the member variable to the place holder in the template
     $parameters = ["crewId" => $this->crewId, "crewCompanyId" => $this->crewCompanyId, "crewLocation" => $this->crewLocation];
     $statement->execute($parameters);
 }
開發者ID:CreativeCorrie,項目名稱:time-crunchers,代碼行數:20,代碼來源:Crew.php

示例3: update

 /**
  * updates this Shift in mySQL
  *
  * @param \PDO $pdo PDO connection object
  * @throws \PDOException when mySQL related errors occur
  * @throws \TypeError if $pdo is not a PDO connection object
  **/
 public function update(\PDO $pdo)
 {
     //enforce the shiftId is not null (i.e., don't update a shift that hasn't been inserted)
     if ($this->shiftId === null) {
         throw new \PDOException("unable to update a shift that does not exist");
     }
     //create query template
     $query = "UPDATE shift SET shiftUserId = :shiftUserId, shiftCrewId = :shiftCrewId, shiftRequestId = :shiftRequestId, shiftStartTime = :shiftStartTime, shiftDuration = :shiftDuration, shiftDate = :shiftDate, shiftDelete = :shiftDelete WHERE shiftId = :shiftId";
     $statement = $pdo->Prepare($query);
     //bind the member variables to the place holders in the template
     $sDate = $this->shiftDate->format("Y-m-d");
     $parameters = ["shiftUserId" => $this->shiftUserId, "shiftCrewId" => $this->shiftCrewId, "shiftRequestId" => $this->shiftRequestId, "shiftStartTime" => $this->shiftStartTime, "shiftDuration" => $this->shiftDuration, "shiftDate" => $sDate, "shiftDelete" => $this->shiftDelete, "shiftId" => $this->shiftId];
     $statement->execute($parameters);
 }
開發者ID:CreativeCorrie,項目名稱:time-crunchers,代碼行數:21,代碼來源:Shift.php


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