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
This commit is contained in:
nate 2008-09-12 02:09:38 +00:00
parent b7b235c2a5
commit 8b3a0a8782
2 changed files with 20 additions and 18 deletions

View file

@ -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) {
function execute($sql, $options = array()) {
$defaults = array('stats' => true, 'log' => $this->fullDebug);
$options = array_merge($defaults, $options);
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 ($this->fullDebug) {
if ($options['log']) {
$this->logQuery($sql);
}

View file

@ -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