当前位置: 首页>>代码示例>>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;未经允许,请勿转载。