Skip to content

Commit

Permalink
Making Connection accepts Query objects
Browse files Browse the repository at this point in the history
  • Loading branch information
jrbasso committed Jan 20, 2014
1 parent 4c24185 commit d0cb098
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/Database/Connection.php
Expand Up @@ -196,10 +196,13 @@ public function isConnected() {
/**
* Prepares a sql statement to be executed
*
* @param string $sql
* @param string|Cake\Database\Query $sql
* @return \Cake\Database\Statement
*/
public function prepare($sql) {
if ($sql instanceof Query) {
$sql = $sql->sql();
}
$statement = $this->_driver->prepare($sql);

if ($this->_logQueries) {
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Query.php
Expand Up @@ -201,7 +201,7 @@ public function connection($connection = null) {
*/
public function execute() {
$query = $this->_transformQuery();
$statement = $this->_connection->prepare($query->sql());
$statement = $this->_connection->prepare($query);
$query->_bindStatement($statement);
$statement->execute();

Expand Down

0 comments on commit d0cb098

Please sign in to comment.