예제 #1
0
 /**
  * @see        DBAdapter::bindValue()
  */
 public function bindValue(PDOStatement $stmt, $parameter, $value, ColumnMap $cMap)
 {
     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());
 }
예제 #2
0
 /**
  * Binds a value to a positioned parameted in a statement,
  * given a ColumnMap object to infer the binding type.
  * Warning: duplicates logic from DefaultPlatform::getColumnBindingPHP().
  * Any code modification here must be ported there.
  *
  * @param     PDOStatement  $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(PDOStatement $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());
 }
예제 #3
0
 /**
  * @see       DBAdapter::bindValue()
  *
  * @param PDOStatement $stmt
  * @param string       $parameter
  * @param mixed        $value
  * @param ColumnMap    $cMap
  * @param null|integer $position
  *
  * @return boolean
  */
 public function bindValue(PDOStatement $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 ($pdoType == PDO::PARAM_BOOL) {
         $value = (int) $value;
         $pdoType = PDO::PARAM_INT;
         return $stmt->bindValue($parameter, $value, $pdoType);
     } elseif ($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);
 }