本文整理汇总了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);
}
示例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);
}
示例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);
}