Ejemplo n.º 1
0
 public function formatOne(StatementInterface $stmt)
 {
     if ($stmt->rowCount() == 0) {
         return null;
     } else {
         return $stmt;
     }
 }
Ejemplo n.º 2
0
 public function formatOne(StatementInterface $stmt)
 {
     $this->checkInit();
     $result = null;
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $result = $this->getAllObjectsFromRow($row);
     }
     $stmt->closeCursor();
     return $result;
 }
Ejemplo n.º 3
0
 public function formatOne(StatementInterface $stmt)
 {
     $this->checkInit();
     $result = null;
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         if ($rowArray = $this->getStructuredArrayFromRow($row)) {
             $result = $rowArray;
         }
     }
     $stmt->closeCursor();
     return $result;
 }
Ejemplo n.º 4
0
 public function formatOne(StatementInterface $stmt)
 {
     $this->checkInit();
     $result = null;
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         if ($object =& $this->getStructuredArrayFromRow($row)) {
             $result =& $object;
         }
     }
     $this->currentObjects = array();
     $this->alreadyHydratedObjects = array();
     $stmt->closeCursor();
     return $result;
 }
Ejemplo n.º 5
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());
 }
Ejemplo n.º 6
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());
 }
 /**
  * Returns the number of rows affected by the last SQL statement
  *
  * rowCount() returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement
  * executed by the corresponding Statement object.
  *
  * If the last SQL statement executed by the associated Statement object was a SELECT statement,
  * some databases may return the number of rows returned by that statement. However,
  * this behaviour is not guaranteed for all databases and should not be
  * relied on for portable applications.
  *
  * @return integer The number of rows.
  */
 public function rowCount()
 {
     return $this->statement->rowCount();
 }
 /**
  * @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);
 }