From 8b3a0a8782ba206a63ff67ee157f753b14bf7213 Mon Sep 17 00:00:00 2001 From: nate Date: Fri, 12 Sep 2008 02:09:38 +0000 Subject: [PATCH] Adding $options param to DboSource::execute() git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7594 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/model/datasources/dbo_source.php | 22 ++++++++++++++-------- cake/tests/lib/cake_test_fixture.php | 16 ++++++---------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 3ac7ebf53..7fe0a8cd7 100644 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -184,17 +184,23 @@ class DboSource extends DataSource { * If DEBUG is set, the log is shown all the time, else it is only shown on errors. * * @param string $sql + * @param array $options * @return mixed Resource or object representing the result set, or false on failure */ - function execute($sql) { - $t = getMicrotime(); - $this->_result = $this->_execute($sql); - $this->took = round((getMicrotime() - $t) * 1000, 0); - $this->affected = $this->lastAffected(); - $this->error = $this->lastError(); - $this->numRows = $this->lastNumRows(); + function execute($sql, $options = array()) { + $defaults = array('stats' => true, 'log' => $this->fullDebug); + $options = array_merge($defaults, $options); - if ($this->fullDebug) { + if ($options['stats']) { + $t = getMicrotime(); + $this->_result = $this->_execute($sql); + $this->took = round((getMicrotime() - $t) * 1000, 0); + $this->affected = $this->lastAffected(); + $this->error = $this->lastError(); + $this->numRows = $this->lastNumRows(); + } + + if ($options['log']) { $this->logQuery($sql); } diff --git a/cake/tests/lib/cake_test_fixture.php b/cake/tests/lib/cake_test_fixture.php index 26360a8e8..96bb193f5 100644 --- a/cake/tests/lib/cake_test_fixture.php +++ b/cake/tests/lib/cake_test_fixture.php @@ -143,11 +143,9 @@ class CakeTestFixture extends Object { } $this->Schema->_build(array($this->table => $this->fields)); - $fullDebug = $db->fullDebug; - $db->fullDebug = false; - $return = ($db->execute($db->createSchema($this->Schema)) !== false); - $db->fullDebug = $fullDebug; - return $return; + return ( + $db->execute($db->createSchema($this->Schema), array('log' => false)) !== false + ); } /** * Run after all tests executed, should return SQL statement to drop table for this fixture. @@ -158,11 +156,9 @@ class CakeTestFixture extends Object { */ function drop(&$db) { $this->Schema->_build(array($this->table => $this->fields)); - $fullDebug = $db->fullDebug; - $db->fullDebug = false; - $return = ($db->execute($db->dropSchema($this->Schema)) !== false); - $db->fullDebug = $fullDebug; - return $return; + return ( + $db->execute($db->dropSchema($this->Schema), array('log' => false)) !== false + ); } /** * Run before each tests is executed, should return a set of SQL statements to insert records for the table