Example #1
0
 /**
  * Binds a PHP variable to a corresponding named or question mark placeholder in the SQL statement
  * that was use to prepare the statement. Unlike PDOStatement::bindValue(), the variable is bound
  * as a reference and will only be evaluated at the time that PDOStatement::execute() is called.
  * 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.
  * @param integer $length         Length of the data type. To indicate that a parameter is an OUT parameter from a stored procedure, you must explicitly set the length.
  * @param mixed   $driver_options
  *
  * @return boolean
  */
 public function bindParam($pos, &$value, $type = \PDO::PARAM_STR, $length = 0, $driver_options = null)
 {
     $return = $this->statement->bindParam($pos, $value, $type, $length, $driver_options);
     if ($this->connection->useDebug) {
         $typestr = isset(self::$typeMap[$type]) ? self::$typeMap[$type] : '(default)';
         $valuestr = $length > 100 ? '[Large 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;
 }
Example #2
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());
 }
Example #3
0
 /**
  * @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)
 {
     if (PropelTypes::CLOB_EMU === $cMap->getType()) {
         return $stmt->bindParam(':p' . $position, $value, $cMap->getPdoType(), strlen($value));
     }
     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());
 }