本文整理汇总了PHP中PDOStatement::bindValue方法的典型用法代码示例。如果您正苦于以下问题:PHP PDOStatement::bindValue方法的具体用法?PHP PDOStatement::bindValue怎么用?PHP PDOStatement::bindValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PDOStatement
的用法示例。
在下文中一共展示了PDOStatement::bindValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bindValueAndExecuteInsertOrUpdate
private function bindValueAndExecuteInsertOrUpdate(PDOStatement $stm, Contact $contact)
{
$stm->bindValue(':name', $contact->getName(), PDO::PARAM_STR);
$stm->bindValue(':photo', $contact->getPhoto(), PDO::PARAM_STR);
$stm->bindValue(':email', $contact->getEmail(), PDO::PARAM_STR);
return $stm->execute();
}
示例2: __construct
public function __construct(Connection $connection, $queryString, array $params)
{
$time = microtime(TRUE);
$this->connection = $connection;
$this->supplementalDriver = $connection->getSupplementalDriver();
$this->queryString = $queryString;
$this->params = $params;
try {
if (substr($queryString, 0, 2) === '::') {
$connection->getPdo()->{substr($queryString, 2)}();
} elseif ($queryString !== NULL) {
static $types = ['boolean' => PDO::PARAM_BOOL, 'integer' => PDO::PARAM_INT, 'resource' => PDO::PARAM_LOB, 'NULL' => PDO::PARAM_NULL];
$this->pdoStatement = $connection->getPdo()->prepare($queryString);
foreach ($params as $key => $value) {
$type = gettype($value);
$this->pdoStatement->bindValue(is_int($key) ? $key + 1 : $key, $value, isset($types[$type]) ? $types[$type] : PDO::PARAM_STR);
}
$this->pdoStatement->setFetchMode(PDO::FETCH_ASSOC);
$this->pdoStatement->execute();
}
} catch (\PDOException $e) {
$e = $this->supplementalDriver->convertException($e);
$e->queryString = $queryString;
throw $e;
}
$this->time = microtime(TRUE) - $time;
}
示例3: __construct
/**
* Constructor
*
* @param PDO $pdo Database connection
* @param string $sql SQL statement
* @param array $params SQL statement parameters
*/
public function __construct(\PDO $pdo, $sql, array $params = array())
{
$this->pdo = $pdo;
$this->statement = $this->pdo->prepare($sql);
foreach ($params as $key => $value) {
$this->statement->bindValue($key, $value);
}
}
示例4: bindValue
public function bindValue($parameter, $value, $dataType = null)
{
if ($dataType === null) {
$dataType = $this->getPdoType($value);
}
$this->statement->bindValue($parameter, $value, $dataType);
return $this;
}
示例5: addTile
/**
* @param int $zoom_level
* @param int $x
* @param int $y
* @param string $data
*/
public function addTile($zoom_level, $x, $y, $data)
{
$this->addTileStmt->bindValue(':z', $zoom_level, \PDO::PARAM_INT);
$this->addTileStmt->bindValue(':x', $x, \PDO::PARAM_INT);
$this->addTileStmt->bindValue(':y', $y, \PDO::PARAM_INT);
$this->addTileStmt->bindValue(':data', $data, \PDO::PARAM_LOB);
$this->addTileStmt->execute();
}
示例6: bindParams
protected function bindParams(array $params, $types)
{
foreach ($params as $key => $param) {
$type = isset($this->type[$types[$key]]) ? $this->type[$types[$key]] : PDO::PARAM_STR;
// Placeholder numbers begins from 1
$this->stmt->bindValue($key + 1, $param, $type);
}
}
示例7: bindFields
protected function bindFields(\PDOStatement $statment, File $file)
{
$statment->bindValue(':fileName', $file->getFileName());
$statment->bindValue(':fileType', $file->getFileType());
$statment->bindValue(':fileSize', $file->getFileSize());
$statment->bindValue(':fileMediaInfo', $file->getFileMediaInfo());
$statment->bindValue(':fileKey', $file->getFileKey());
}
示例8: setParameters
private function setParameters()
{
if (isset($this->binds) && !empty($this->binds)) {
foreach ($this->binds as $index => $value) {
$this->delete->bindValue(":{$index}", $value, is_int($value) ? PDO::PARAM_INT : PDO::PARAM_STR);
}
}
}
示例9: bindValueHelper
/**
* Associe les valeurs aux paramètres de la requète
*
* @param PDOStatement $stmt le statement préparé avec la requète sql
* @param array $values les valeurs à associer
* @return type le statement avec toutes les associations de faites
*/
private function bindValueHelper($stmt, $values)
{
$stmt->bindValue(':title', $values['title'], PDO::PARAM_STR);
$stmt->bindValue(':short_desc', $values['short_desc'], PDO::PARAM_STR);
$stmt->bindValue(':long_desc', $values['long_desc'], PDO::PARAM_STR);
$stmt->bindValue(':director', $values['director'], PDO::PARAM_STR);
$stmt->bindValue(':year', $values['year'], PDO::PARAM_STR);
$stmt->bindValue(':image', $values['image'], PDO::PARAM_STR);
return $stmt;
}
示例10: getTile
/**
* For every tile needed, this function will be called
*
* Return the blob of this image
* @param Tile $tile
* @throws TileNotAvailableException
* @return string Blob of this image
*/
public function getTile(Tile $tile)
{
$this->tile_fetcher->bindValue(':x', $tile->x);
$this->tile_fetcher->bindValue(':y', $tile->y);
$this->tile_fetcher->execute();
$tile_data = $this->tile_fetcher->fetchColumn();
if ($tile_data === false) {
throw new TileNotAvailableException();
}
return $tile_data;
}
示例11: getSyntax
private function getSyntax()
{
if ($this->Places) {
foreach ($this->Places as $Vinculo => $Valor) {
if ($Vinculo == 'limit' || $Vinculo == 'offset') {
$Valor = (int) $Valor;
}
$this->Read->bindValue(":{$Vinculo}", $Valor, is_int($Valor) ? PDO::PARAM_INT : PDO::PARAM_STR);
}
}
}
示例12: getSyntax
private function getSyntax()
{
if ($this->Places) {
foreach ($this->Places as $Bind => $Value) {
if ($Bind == 'limit' || $Bind == 'offset') {
$Value = (int) $Value;
}
$this->Read->bindValue(":{$Bind}", $Value, is_int($Value) ? PDO::PARAM_INT : PDO::PARAM_STR);
}
}
}
示例13: bindValues
protected function bindValues(\PDOStatement $stmt)
{
$request = $this->getRequest();
$stmt->bindValue(1, $request->getClientIp());
$stmt->bindValue(2, $request->get('User'));
if (strpos(strtoupper($this->getCommandName()), 'ALL') > 0) {
$stmt->bindValue(3, $request->get('Consulta'));
return;
}
$stmt->bindValue(3, $request->get('ID'));
$stmt->bindValue(4, $request->get('Consulta'));
}
示例14: doSetSystemFields
/**
* doSetSystemFields
*
* @param PDOStatement $stmt
* @param KVDdom_DomainObject $domaiObject
* @param integer $startIndex
* @return integer Volgende te gebruiken index.
*/
public function doSetSystemFields($stmt, $domainObject, $startIndex)
{
if (!$domainObject->hasSystemFields()) {
throw new LogicException('Kan de systemFields van een object dat geen systemFields heeft niet instellen op een statement.');
}
$stmt->bindValue($startIndex++, $domainObject->getSystemFields()->getAangemaaktDoor(), PDO::PARAM_STR);
$stmt->bindValue($startIndex++, $domainObject->getsystemFields()->getAangemaaktOp()->format(DATE_ISO8601), PDO::PARAM_STR);
$stmt->bindValue($startIndex++, $domainObject->getSystemFields()->getTargetVersie(), PDO::PARAM_INT);
$stmt->bindValue($startIndex++, $domainObject->getSystemFields()->getBewerktDoor(), PDO::PARAM_STR);
$stmt->bindValue($startIndex++, $domainObject->getSystemFields()->getBewerktOp()->format(DATE_ISO8601), PDO::PARAM_STR);
return $startIndex;
}
示例15: execute
/**
* @method execute
* @param $query|string
* @return DataBase
*/
public function execute($query)
{
$this->error = false;
if ($query) {
if ($this->query = $this->pdo->prepare($this->escapeDoubleSpaces($query))) {
if (count($this->paramArray)) {
foreach ($this->paramArray as $param => $val) {
if (is_null($val)) {
$var = PDO::PARAM_NULL;
} elseif (is_int($val)) {
$var = PDO::PARAM_INT;
} elseif (is_bool($val)) {
$var = PDO::PARAM_BOOL;
} else {
$var = PDO::PARAM_STR;
if ($this->queryType === self::QUERY_TYPE_UPDATE) {
$val = $this->wrapInSingleQuotes($val);
}
}
$this->query->bindValue($param, $val, $var);
}
#End Foreach
}
if ($this->query->execute()) {
$this->results = $this->query->fetchAll(PDO::FETCH_OBJ);
$this->count = $this->query->rowCount();
} else {
$this->error = true;
}
}
}
$this->reset();
return $this;
}