Skip to content
Permalink
Browse files

Implementing Connection::query() and added test

  • Loading branch information...
lorenzo committed May 30, 2012
1 parent 83a878f commit 193594c0406c1ceaacd85c98a430e0788697b54e
@@ -118,7 +118,7 @@ public function execute($query, array $params = array(), array $types = array())
$this->_bindValues($statement, $params, $types);
$result = $statement->execute();
} else {
$result = $this->query($query);
$statement = $this->query($query);
}
return $statement;
}
@@ -129,7 +129,10 @@ public function execute($query, array $params = array(), array $types = array())
* @return Cake\Model\Datasource\Database\Statement
**/
public function query($sql) {
$this->connect();
$statement = $this->prepare($sql);
$statement->execute();
return $statement;
}
/**
@@ -153,5 +153,17 @@ public function testExecuteWithMissingType() {
$statement = $this->connection->execute($sql, array(new \DateTime('2012-01-01')), array('bar'));
}
/**
* Tests executing a qury with no params also works
*
* @return void
**/
public function testExecuteWithNoParams() {
$sql = 'SELECT 1';
$statement = $this->connection->execute($sql);
$result = $statement->fetch();
$this->assertCount(1, $result);
$this->assertEquals(array(1), $result);
}
}

0 comments on commit 193594c

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