Making database stats dependent of fullDebug

Leaving lastNumRows commented out until some bugs are solved
This commit is contained in:
José Lorenzo Rodríguez 2010-10-17 18:36:35 -04:30
parent 10646ba2ad
commit bcc1417e5d
2 changed files with 8 additions and 8 deletions

View file

@ -299,7 +299,11 @@ class DboMysql extends DboSource {
*/ */
function lastNumRows() { function lastNumRows() {
if ($this->hasResult()) { if ($this->hasResult()) {
return mysql_num_rows($this->_result); $i = 0;
foreach ($this->_result as $row) {
$i++;
}
return $i;
} }
return null; return null;
} }

View file

@ -230,8 +230,6 @@ class DboSource extends DataSource {
* *
* ### Options * ### 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. * - log - Whether or not the query should be logged to the memory log.
* *
* @param string $sql * @param string $sql
@ -240,19 +238,17 @@ class DboSource extends DataSource {
* @return mixed Resource or object representing the result set, or false on failure * @return mixed Resource or object representing the result set, or false on failure
*/ */
public function execute($sql, $options = array(), $params = array()) { 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); $options = array_merge($defaults, $options);
$this->error = null; $this->error = null;
$t = microtime(true); $t = microtime(true);
$this->_result = $this->_execute($sql, $params); $this->_result = $this->_execute($sql, $params);
if ($options['stats']) {
if ($options['log']) {
$this->took = round((microtime(true) - $t) * 1000, 0); $this->took = round((microtime(true) - $t) * 1000, 0);
$this->affected = $this->lastAffected(); $this->affected = $this->lastAffected();
//$this->numRows = $this->lastNumRows(); //$this->numRows = $this->lastNumRows();
}
if ($options['log']) {
$this->logQuery($sql); $this->logQuery($sql);
} }