Permalink
Browse files

Making Connection accepts Query objects

  • Loading branch information...
1 parent 4c24185 commit d0cb098c39854efc6a4b6fb4cbda62139dea2abc @jrbasso jrbasso committed Jan 20, 2014
Showing with 5 additions and 2 deletions.
  1. +4 −1 src/Database/Connection.php
  2. +1 −1 src/Database/Query.php
@@ -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) {
@@ -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();

0 comments on commit d0cb098

Please sign in to comment.