/**
  * Binds a value to a corresponding named or question mark placeholder in the SQL statement
  * that was use to prepare the statement. Returns a boolean value indicating success.
  *
  * @param integer $pos   Parameter identifier (for determining what to replace in the query).
  * @param mixed   $value The value to bind to the parameter.
  * @param integer $type  Explicit data type for the parameter using the PDO::PARAM_* constants. Defaults to PDO::PARAM_STR.
  *
  * @return boolean
  */
 public function bindValue($pos, $value, $type = \PDO::PARAM_STR)
 {
     $return = $this->statement->bindValue($pos, $value, $type);
     if ($this->connection->useDebug) {
         $typestr = isset(self::$typeMap[$type]) ? self::$typeMap[$type] : '(default)';
         $valuestr = $type == \PDO::PARAM_LOB ? '[LOB value]' : var_export($value, true);
         $this->boundValues[$pos] = $valuestr;
         $msg = sprintf('Binding %s at position %s w/ PDO type %s', $valuestr, $pos, $typestr);
         $this->connection->log($msg);
     }
     return $return;
 }
Exemple #2
0
 /**
  * Binds a value to a positioned parameter in a statement,
  * given a ColumnMap object to infer the binding type.
  *
  * @param StatementInterface $stmt      The statement to bind
  * @param string             $parameter Parameter identifier
  * @param mixed              $value     The value to bind
  * @param ColumnMap          $cMap      The ColumnMap of the column to bind
  * @param null|integer       $position  The position of the parameter to bind
  *
  * @return boolean
  */
 public function bindValue(StatementInterface $stmt, $parameter, $value, ColumnMap $cMap, $position = null)
 {
     if ($cMap->isTemporal()) {
         $value = $this->formatTemporalValue($value, $cMap);
     } elseif (is_resource($value) && $cMap->isLob()) {
         // we always need to make sure that the stream is rewound, otherwise nothing will
         // get written to database.
         rewind($value);
     }
     return $stmt->bindValue($parameter, $value, $cMap->getPdoType());
 }
Exemple #3
0
 /**
  * @see       AbstractAdapter::bindValue()
  *
  * @param     PDOStatement  $stmt
  * @param     string        $parameter
  * @param     mixed         $value
  * @param     ColumnMap     $cMap
  * @param     null|integer  $position
  *
  * @return    boolean
  */
 public function bindValue(StatementInterface $stmt, $parameter, $value, ColumnMap $cMap, $position = null)
 {
     if ($cMap->isTemporal()) {
         $value = $this->formatTemporalValue($value, $cMap);
     } elseif (is_resource($value) && $cMap->isLob()) {
         // we always need to make sure that the stream is rewound, otherwise nothing will
         // get written to database.
         rewind($value);
         // pdo_sqlsrv must have bind binaries using bindParam so that the PDO::SQLSRV_ENCODING_BINARY
         // driver option can be utilized. This requires a unique blob parameter because the bindParam
         // value is passed by reference and if we didn't do this then the referenced parameter value
         // would change on the next loop
         $blob = "blob" . $position;
         ${$blob} = $value;
         return $stmt->bindParam($parameter, ${$blob}, PDO::PARAM_LOB, 0, PDO::SQLSRV_ENCODING_BINARY);
     }
     return $stmt->bindValue($parameter, $value, $cMap->getPdoType());
 }
 /**
  * @see AdapterInterface::bindValue()
  *
  * @param StatementInterface $stmt
  * @param string             $parameter
  * @param mixed              $value
  * @param ColumnMap          $cMap
  * @param null|integer       $position
  *
  * @return boolean
  */
 public function bindValue(StatementInterface $stmt, $parameter, $value, ColumnMap $cMap, $position = null)
 {
     $pdoType = $cMap->getPdoType();
     // FIXME - This is a temporary hack to get around apparent bugs w/ PDO+MYSQL
     // See http://pecl.php.net/bugs/bug.php?id=9919
     if (\PDO::PARAM_BOOL === $pdoType) {
         $value = (int) $value;
         $pdoType = \PDO::PARAM_INT;
         return $stmt->bindValue($parameter, $value, $pdoType);
     }
     if ($cMap->isTemporal()) {
         $value = $this->formatTemporalValue($value, $cMap);
     } elseif (is_resource($value) && $cMap->isLob()) {
         // we always need to make sure that the stream is rewound, otherwise nothing will
         // get written to database.
         rewind($value);
     }
     return $stmt->bindValue($parameter, $value, $pdoType);
 }