当前位置: 首页>>代码示例>>PHP>>正文


PHP PDOStatement::bindValue方法代码示例

本文整理汇总了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();
 }
开发者ID:lga37,项目名称:contacts,代码行数:7,代码来源:ContactSQLStorage.php

示例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;
 }
开发者ID:nette,项目名称:database,代码行数:27,代码来源:ResultSet.php

示例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);
     }
 }
开发者ID:lmkhang,项目名称:mcntw,代码行数:15,代码来源:PdoReader.php

示例4: bindValue

 public function bindValue($parameter, $value, $dataType = null)
 {
     if ($dataType === null) {
         $dataType = $this->getPdoType($value);
     }
     $this->statement->bindValue($parameter, $value, $dataType);
     return $this;
 }
开发者ID:shiwolang,项目名称:db,代码行数:8,代码来源:Statement.php

示例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();
 }
开发者ID:html24,项目名称:mbtiles-generator,代码行数:14,代码来源:MBTileFile.php

示例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);
     }
 }
开发者ID:nafigator,项目名称:Veles,代码行数:8,代码来源:PdoAdapter.php

示例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());
 }
开发者ID:sgscode,项目名称:uppy,代码行数:8,代码来源:FileMapper.php

示例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);
         }
     }
 }
开发者ID:Ritotsume,项目名称:schoolbus,代码行数:8,代码来源:Delete.class.php

示例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;
 }
开发者ID:polytechlyon-isi1web,项目名称:mymovies-GaetanMartin,代码行数:17,代码来源:Movie.php

示例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;
 }
开发者ID:html24,项目名称:mbtiles-generator,代码行数:19,代码来源:MBTilesTileSource.php

示例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);
         }
     }
 }
开发者ID:jairophp,项目名称:amarmais,代码行数:11,代码来源:Read.php

示例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);
         }
     }
 }
开发者ID:arthurleon,项目名称:ytradio,代码行数:11,代码来源:Read.class.php

示例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'));
 }
开发者ID:javiermadueno,项目名称:bestclone,代码行数:12,代码来源:AbstractModificadorProvincia.php

示例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;
 }
开发者ID:Tjoosten,项目名称:kvd,代码行数:20,代码来源:KVDdom_ChangeableSystemFieldsMapper.class.php

示例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;
 }
开发者ID:ecne,项目名称:ecne-framework,代码行数:39,代码来源:DataBase.php


注:本文中的PDOStatement::bindValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。