Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Passing the query object to drivers to prepare the sql

  • Loading branch information...
commit 79ff83d3330131e6b0fb71f4e47b1a19b5b6429e 1 parent d0cb098
@jrbasso jrbasso authored
View
3  src/Database/Connection.php
@@ -200,9 +200,6 @@ public function isConnected() {
* @return \Cake\Database\Statement
*/
public function prepare($sql) {
- if ($sql instanceof Query) {
- $sql = $sql->sql();
- }
$statement = $this->_driver->prepare($sql);
if ($this->_logQueries) {
View
4 src/Database/Driver.php
@@ -92,10 +92,10 @@ public function __construct($config = []) {
/**
* Prepares a sql statement to be executed
*
- * @param string $sql
+ * @param string|Cake\Database\Query $query
* @return Cake\Database\Statement
*/
- public abstract function prepare($sql);
+ public abstract function prepare($query);
/**
* Starts a transaction
View
6 src/Database/Driver/PDODriverTrait.php
@@ -16,6 +16,7 @@
*/
namespace Cake\Database\Driver;
+use Cake\Database\Query;
use Cake\Database\Statement\PDOStatement;
use PDO;
@@ -71,11 +72,12 @@ public function disconnect() {
/**
* Prepares a sql statement to be executed
*
- * @param string $sql
+ * @param string|Cake\Database\Query $query
* @return Cake\Database\Statement
*/
- public function prepare($sql) {
+ public function prepare($query) {
$this->connect();
+ $sql = $query instanceof Query ? $query->sql() : $query;
$statement = $this->_connection->prepare($sql);
return new PDOStatement($statement, $this);
}
View
6 src/Database/Driver/Sqlite.php
@@ -17,6 +17,7 @@
namespace Cake\Database\Driver;
use Cake\Database\Dialect\SqliteDialectTrait;
+use Cake\Database\Query;
use Cake\Database\Statement\PDOStatement;
use Cake\Database\Statement\SqliteStatement;
use PDO;
@@ -84,11 +85,12 @@ public function enabled() {
/**
* Prepares a sql statement to be executed
*
- * @param string $sql
+ * @param string|Cake\Database\Query $query
* @return Cake\Database\Statement
*/
- public function prepare($sql) {
+ public function prepare($query) {
$this->connect();
+ $sql = $query instanceof Query ? $query->sql() : $query;
$statement = $this->_connection->prepare($sql);
return new SqliteStatement(new PDOStatement($statement, $this), $this);
}
Please sign in to comment.
Something went wrong with that request. Please try again.