Skip to content
Permalink
Browse files

Changing param order in execute() to maintain compatibility, making a…

…ll tests pass
  • Loading branch information...
lorenzo committed Oct 17, 2010
1 parent 25915bd commit 082873721cf6cd24e3b85235d6caceb32fee6597
@@ -235,11 +235,11 @@ public function rawQuery($sql, $params = array()) {
* - log - Whether or not the query should be logged to the memory log.
*
* @param string $sql
* @param array $params values to be bided to the query
* @param array $options
* @param array $params values to be bided to the query
* @return mixed Resource or object representing the result set, or false on failure
*/
public function execute($sql, $params = array(), $options = array()) {
public function execute($sql, $options = array(), $params = array()) {
$defaults = array('stats' => true, 'log' => $this->fullDebug);
$options = array_merge($defaults, $options);
@@ -267,17 +267,19 @@ public function execute($sql, $params = array(), $options = array()) {
*
* @param string $sql SQL statement
* @param array $params list of params to be bound to query
* @return PDOStatement if query executes with no problem, false otherwise
* @return PDOStatement if query executes with no problem, true as the result of a succesfull
* query returning no rows, suchs as a CREATE statement, false otherwise
*/
protected function _execute($sql, $params = array()) {
$query = $this->_connection->prepare($sql);
$query->setFetchMode(PDO::FETCH_LAZY);
if (!$query->execute($params)) {
debug($query->errorInfo());
$this->error = $this->lastError();
return false;
}
if (!$query->columnCount()) {
return true;
}
return $query;
}
@@ -4220,11 +4220,11 @@ function testFetchAllBooleanReturns() {
$name = $this->db->fullTableName('test_query');
$query = "CREATE TABLE {$name} (name varchar(10));";
$result = $this->db->query($query);
$this->assertTrue($result, 'Query did not return a boolean. %s');
$this->assertTrue($result, 'Query did not return a boolean');
$query = "DROP TABLE {$name};";
$result = $this->db->fetchAll($query);
$this->assertTrue($result, 'Query did not return a boolean. %s');
$result = $this->db->query($query);
$this->assertTrue($result, 'Query did not return a boolean');
}
/**
@@ -4563,7 +4563,7 @@ function testReadOnlyCallingQueryAssociationWhenDefined() {
ConnectionManager::create('test_no_queryAssociation', array(
'datasource' => 'data'
));
$Article =& ClassRegistry::init('Article');
$Article = ClassRegistry::init('Article');
$Article->Comment->useDbConfig = 'test_no_queryAssociation';
$result = $Article->find('all');
$this->assertTrue(is_array($result));

0 comments on commit 0828737

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