From bcc1417e5dbcdd9f371ed280c4b983c892e10e10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sun, 17 Oct 2010 18:36:35 -0430 Subject: [PATCH] Making database stats dependent of fullDebug Leaving lastNumRows commented out until some bugs are solved --- cake/libs/model/datasources/dbo/dbo_mysql.php | 6 +++++- cake/libs/model/datasources/dbo_source.php | 10 +++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 40bf6c485..1d5706cfc 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -299,7 +299,11 @@ class DboMysql extends DboSource { */ function lastNumRows() { if ($this->hasResult()) { - return mysql_num_rows($this->_result); + $i = 0; + foreach ($this->_result as $row) { + $i++; + } + return $i; } return null; } diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index cb64234c3..76305f5a6 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -230,8 +230,6 @@ class DboSource extends DataSource { * * ### Options * - * - stats - Collect meta data stats for this query. Stats include time take, rows affected, - * any errors, and number of rows returned. Defaults to `true`. * - log - Whether or not the query should be logged to the memory log. * * @param string $sql @@ -240,19 +238,17 @@ class DboSource extends DataSource { * @return mixed Resource or object representing the result set, or false on failure */ public function execute($sql, $options = array(), $params = array()) { - $defaults = array('stats' => true, 'log' => $this->fullDebug); + $defaults = array('log' => $this->fullDebug); $options = array_merge($defaults, $options); $this->error = null; $t = microtime(true); $this->_result = $this->_execute($sql, $params); - if ($options['stats']) { + + if ($options['log']) { $this->took = round((microtime(true) - $t) * 1000, 0); $this->affected = $this->lastAffected(); //$this->numRows = $this->lastNumRows(); - } - - if ($options['log']) { $this->logQuery($sql); }