本文整理汇总了PHP中resource::rowCount方法的典型用法代码示例。如果您正苦于以下问题:PHP resource::rowCount方法的具体用法?PHP resource::rowCount怎么用?PHP resource::rowCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类resource
的用法示例。
在下文中一共展示了resource::rowCount方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: num_rows
/**
* 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: _parseResults
/**
* @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: __construct
/**
* 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: affected_rows
/**
* 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: getNumRows
/**
* 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: getNumRows
/**
* 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: getRowsNum
/**
* 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: affectedRows
/**
* 取出最后一次查询影响的行数
*
* @param resource $resource 查询的资源数据
* @param mixed $handle 连接对象
* @return integer
*/
public function affectedRows($resource, $handle)
{
return $resource->rowCount();
}
示例9: numRows
/**
* Fetch number of rows in a query result.
*
* @param resource $sth
* PDOStatement resource.
*
* @return int
*/
public function numRows($sth)
{
return $sth->rowCount();
}
示例10: getNumRows
/**
* 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: getAffectedRows
/**
* Returns the number of affected rows.
*
* @return int Returns the number of affected rows.
*/
public function getAffectedRows()
{
return $this->result->rowCount();
}
示例12: db_driver_affected_count
/**
* Get the affected count from the database.
*
* @param resource $resource
*
* @return int
*/
function db_driver_affected_count($resource)
{
global $_db;
return $resource->rowCount();
}