當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。