Skip to content
Permalink
Browse files

Fixing issues with DboSource::execute() where queries would not be ru…

…n if stats = false in the options. Tests added.
  • Loading branch information...
markstory committed Sep 30, 2009
1 parent 778a6b9 commit 6dbba17d1b3a670c8e8a35ea1e28310343bb3db5
@@ -184,9 +184,9 @@ function execute($sql, $options = array()) {
$defaults = array('stats' => true, 'log' => $this->fullDebug);
$options = array_merge($defaults, $options);
$t = getMicrotime();
$this->_result = $this->_execute($sql);
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();
@@ -3799,6 +3799,27 @@ function testLog() {
$this->testDb->error = $oldError;
Configure::write('debug', $oldDebug);
}
/**
* test that execute runs queries.
*
* @return void
**/
function testExecute() {
$query = 'SELECT * FROM ' . $this->testDb->fullTableName('articles') . ' WHERE 1 = 1';
$this->db->_result = null;
$this->db->took = null;
$this->db->affected = null;
$result = $this->db->execute($query, array('stats' => false));
$this->assertNotNull($result, 'No query performed! %s');
$this->assertNull($this->db->took, 'Stats were set %s');
$this->assertNull($this->db->affected, 'Stats were set %s');
$result = $this->db->execute($query);
$this->assertNotNull($result, 'No query performed! %s');
$this->assertNotNull($this->db->took, 'Stats were not set %s');
$this->assertNotNull($this->db->affected, 'Stats were not set %s');
}
/**
* test ShowQuery generation of regular and error messages
*

0 comments on commit 6dbba17

Please sign in to comment.
You can’t perform that action at this time.