mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
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:
parent
b7b235c2a5
commit
8b3a0a8782
2 changed files with 20 additions and 18 deletions
|
@ -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.
|
* If DEBUG is set, the log is shown all the time, else it is only shown on errors.
|
||||||
*
|
*
|
||||||
* @param string $sql
|
* @param string $sql
|
||||||
|
* @param array $options
|
||||||
* @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
|
||||||
*/
|
*/
|
||||||
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();
|
$t = getMicrotime();
|
||||||
$this->_result = $this->_execute($sql);
|
$this->_result = $this->_execute($sql);
|
||||||
$this->took = round((getMicrotime() - $t) * 1000, 0);
|
$this->took = round((getMicrotime() - $t) * 1000, 0);
|
||||||
$this->affected = $this->lastAffected();
|
$this->affected = $this->lastAffected();
|
||||||
$this->error = $this->lastError();
|
$this->error = $this->lastError();
|
||||||
$this->numRows = $this->lastNumRows();
|
$this->numRows = $this->lastNumRows();
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->fullDebug) {
|
if ($options['log']) {
|
||||||
$this->logQuery($sql);
|
$this->logQuery($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -143,11 +143,9 @@ class CakeTestFixture extends Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->Schema->_build(array($this->table => $this->fields));
|
$this->Schema->_build(array($this->table => $this->fields));
|
||||||
$fullDebug = $db->fullDebug;
|
return (
|
||||||
$db->fullDebug = false;
|
$db->execute($db->createSchema($this->Schema), array('log' => false)) !== false
|
||||||
$return = ($db->execute($db->createSchema($this->Schema)) !== false);
|
);
|
||||||
$db->fullDebug = $fullDebug;
|
|
||||||
return $return;
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Run after all tests executed, should return SQL statement to drop table for this fixture.
|
* 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) {
|
function drop(&$db) {
|
||||||
$this->Schema->_build(array($this->table => $this->fields));
|
$this->Schema->_build(array($this->table => $this->fields));
|
||||||
$fullDebug = $db->fullDebug;
|
return (
|
||||||
$db->fullDebug = false;
|
$db->execute($db->dropSchema($this->Schema), array('log' => false)) !== false
|
||||||
$return = ($db->execute($db->dropSchema($this->Schema)) !== false);
|
);
|
||||||
$db->fullDebug = $fullDebug;
|
|
||||||
return $return;
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Run before each tests is executed, should return a set of SQL statements to insert records for the table
|
* Run before each tests is executed, should return a set of SQL statements to insert records for the table
|
||||||
|
|
Loading…
Add table
Reference in a new issue