コード例 #1
0
ファイル: MyResult.php プロジェクト: xiehaowei/php
 /**
  * Number of rows in the result set
  *
  * @return	int
  */
 public function num_rows()
 {
     if (is_int($this->num_rows)) {
         return $this->num_rows;
     } elseif (count($this->result_array) > 0) {
         return $this->num_rows = count($this->result_array);
     } elseif (count($this->result_object) > 0) {
         return $this->num_rows = count($this->result_object);
     } elseif (($num_rows = $this->result_id->rowCount()) > 0) {
         return $this->num_rows = $num_rows;
     }
     return $this->num_rows = count($this->result_array());
 }
コード例 #2
0
ファイル: Model.php プロジェクト: alfabrad/kidzania-coupon
 /**
  * @method  _parseResults()
  * @access  private
  * @throws  Exception
  * @desc    Parsea los resultados obtenidos en cualquier ejecución de consultas SQL.
  * @see     self::_throwModelException()
  */
 private function _parseResults()
 {
     $this->_resultSet = array();
     $statementWords = explode(' ', $this->_sqlQuery);
     if (preg_match('/SELECT/', strtoupper($statementWords[0]))) {
         $statement = $this->_PDOmySQLConn->prepare($this->_sqlQuery);
         $statement->execute();
         $this->_numRows = $statement->rowCount();
         if ((int) $this->_numRows > 0) {
             while ($row = $this->_resource->fetch(PDO::FETCH_ASSOC)) {
                 array_push($this->_resultSet, $row);
             }
         }
     } else {
         $this->_numRows = $this->_resource->rowCount();
     }
 }
コード例 #3
0
ファイル: query.php プロジェクト: davidmottet/automne
 /**
  * Constructor.
  * Initializes the connection and launches the query.
  *
  * @param string $sql The sql statement
  * @param string $dsn The database dsn
  * @param string $user The database user
  * @param string $pass The database password
  * @return void
  * @access public
  */
 public function __construct($sql = '', $dsn = APPLICATION_DB_DSN, $user = APPLICATION_DB_USER, $pass = APPLICATION_DB_PASSWORD)
 {
     $this->_sql = trim($sql);
     $this->_connect($dsn, $user, $pass);
     if ($this->_sql && $this->_db) {
         /*only for stats*/
         if (STATS_DEBUG) {
             $time_start = CMS_stats::getmicrotime();
         }
         if (preg_match("#^(insert|update)#i", $this->_sql)) {
             $this->_numRows = $this->_db->exec($this->_sql);
             if (preg_match("#^insert#i", $this->_sql)) {
                 $this->_lastInsertedID = $this->_db->lastInsertId();
             }
             $errorInfos = $this->_db->errorInfo();
             if (isset($errorInfos[2])) {
                 $clean_sql = str_replace("\n", "", $this->_sql);
                 $clean_sql = preg_replace("#\t+#", " ", $clean_sql);
                 $errorInfo = isset($errorInfos[2]) ? $errorInfos[2] : 'No error returned';
                 $this->raiseError('Database querying failed : ' . $errorInfo . "\nQuery : " . $clean_sql);
             }
         } else {
             $this->_result = $this->_db->query($this->_sql);
             if ($this->_result) {
                 $this->_numRows = $this->_result->rowCount();
             } else {
                 $clean_sql = str_replace("\n", "", $this->_sql);
                 $clean_sql = preg_replace("#\t+#", " ", $clean_sql);
                 $errorInfos = $this->_db->errorInfo();
                 $errorInfo = isset($errorInfos[2]) ? $errorInfos[2] : 'No error returned';
                 $this->raiseError('Database querying failed : ' . $errorInfo . "\nQuery : " . $clean_sql . "\nFrom : " . io::getCallInfos(3));
             }
         }
         /*only for stats*/
         if (STATS_DEBUG) {
             $currenttime = CMS_stats::getmicrotime();
             $time = $currenttime - $time_start;
             if (VIEW_SQL) {
                 CMS_stats::$sqlTable[] = array('sql' => $this->_sql, 'time' => $time, 'current' => $currenttime - CMS_stats::$timeStart, 'from' => io::getCallInfos(3), 'memory' => memory_get_usage(), 'peak' => memory_get_peak_usage());
             }
             CMS_stats::$sqlNbRequests++;
             CMS_stats::$totalTime += $time;
         }
     }
 }
コード例 #4
0
ファイル: pdo.php プロジェクト: ocidfigueroa/sice
 /**
  * Numero de Filas afectadas en un insert, update o delete
  *
  * @param resource $pdo_statement
  * @deprecated
  * @return int
  */
 public function affected_rows($pdo_statement = NULL)
 {
     if (!$this->pdo) {
         throw new KumbiaException('No hay conexión para realizar esta acción');
     }
     if ($pdo_statement) {
         try {
             $row_count = $pdo_statement->rowCount();
             if ($row_count === false) {
                 throw new KumbiaException($this->error(" al ejecutar <em>\"{$sql_query}\"</em>"));
             }
             return $row_count;
         } catch (PDOException $e) {
             throw new KumbiaException($this->error($e->getMessage()));
         }
     } else {
         return $this->affected_rows;
     }
 }
コード例 #5
0
ファイル: pdo.php プロジェクト: n3t/joomla-cms
 /**
  * Get the number of returned rows for the previous executed SQL statement.
  *
  * @param   resource  $cursor  An optional database cursor resource to extract the row count from.
  *
  * @return  integer   The number of returned rows.
  *
  * @since   12.1
  */
 public function getNumRows($cursor = null)
 {
     $this->connect();
     if ($cursor instanceof PDOStatement) {
         return $cursor->rowCount();
     } elseif ($this->prepared instanceof PDOStatement) {
         return $this->prepared->rowCount();
     } else {
         return 0;
     }
 }
コード例 #6
0
 /**
  * Get the number of returned rows for the previous executed SQL statement.
  *
  * @param   resource $cursor An optional database cursor resource to extract the row count from.
  *
  * @return  integer   The number of returned rows.
  */
 public function getNumRows($cursor = null)
 {
     if ($cursor instanceof \PDOStatement) {
         return $cursor->rowCount();
     }
     if ($this->cursor instanceof \PDOStatement) {
         return $this->cursor->rowCount();
     }
     return 0;
 }
コード例 #7
0
ファイル: mysqldatabase.php プロジェクト: redmexico/XoopsCore
 /**
  * Get number of rows in result
  *
  * @param resource $result the resource containing the number of rows
  *
  * @return int the number of rows to return
  * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
  */
 public function getRowsNum($result)
 {
     Xoops::getInstance()->deprecated('getRowsNum is deprecated and not dependable.');
     //$this->deprecated();
     return $result->rowCount();
 }
コード例 #8
0
ファイル: Pdo.php プロジェクト: menmenweiwei/blog
 /**
  * 取出最后一次查询影响的行数
  *
  * @param resource $resource 查询的资源数据
  * @param mixed $handle 连接对象
  * @return integer
  */
 public function affectedRows($resource, $handle)
 {
     return $resource->rowCount();
 }
コード例 #9
0
ファイル: xstore.php プロジェクト: xqus/xstore
 /**
  * Fetch number of rows in a query result.
  *
  * @param resource $sth
  *   PDOStatement resource.
  *
  * @return int
  */
 public function numRows($sth)
 {
     return $sth->rowCount();
 }
コード例 #10
0
ファイル: pdo.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Get the number of returned rows for the previous executed SQL statement.
  *
  * @param   resource  $cursor  An optional database cursor resource to extract the row count from.
  *
  * @return  integer   The number of returned rows.
  *
  * @since   11.1
  */
 public function getNumRows($cursor = null)
 {
     return $cursor ? $cursor->rowCount() : $this->cursor->rowCount();
 }
コード例 #11
0
 /**
  * Returns the number of affected rows.
  * 
  * @return int Returns the number of affected rows.
  */
 public function getAffectedRows()
 {
     return $this->result->rowCount();
 }
コード例 #12
0
ファイル: db_pdo.php プロジェクト: refirio/levis
/**
 * Get the affected count from the database.
 *
 * @param resource $resource
 *
 * @return int
 */
function db_driver_affected_count($resource)
{
    global $_db;
    return $resource->rowCount();
}