summaryrefslogtreecommitdiffstats
path: root/system/database
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-07-09 14:53:19 +0200
committerAndrey Andreev <narf@bofh.bg>2012-07-09 14:53:19 +0200
commit31380e88dd6af1d91ef1de0425b320706462e887 (patch)
treeba3d25593db38afa9ffd4510a0fac3a16041a963 /system/database
parenta8126b18a37d211240df254a82031e736eb98daf (diff)
Alter CI_DB_pdo_result::num_rows()
Diffstat (limited to 'system/database')
-rw-r--r--system/database/drivers/pdo/pdo_result.php23
1 files changed, 12 insertions, 11 deletions
diff --git a/system/database/drivers/pdo/pdo_result.php b/system/database/drivers/pdo/pdo_result.php
index a366a5f12..44fdd6dc5 100644
--- a/system/database/drivers/pdo/pdo_result.php
+++ b/system/database/drivers/pdo/pdo_result.php
@@ -26,26 +26,27 @@
*/
class CI_DB_pdo_result extends CI_DB_result {
+ public $num_rows;
+
/**
* Number of rows in the result set
*
- * @access public
- * @return integer
+ * @return int
*/
- function num_rows()
+ public function num_rows()
{
- if (is_numeric(stripos($this->result_id->queryString, 'SELECT')))
+ if (is_int($this->num_rows))
{
- $dbh = $this->conn_id;
- $query = $dbh->query($this->result_id->queryString);
- $result = $query->fetchAll();
- unset($dbh, $query);
- return count($result);
+ return $this->num_rows;
}
- else
+ elseif (($this->num_rows = $this->result_id->rowCount()) > 0)
{
- return $this->result_id->rowCount();
+ return $this->num_rows;
}
+
+ $this->num_rows = count($this->result_id->fetchAll());
+ $this->result_id->execute();
+ return $this->num_rows;
}
// --------------------------------------------------------------------