Permalink
Browse files

Not using bindTo(), it is not implemented in hhvm

  • Loading branch information...
1 parent 635757a commit 3c4d9ccbcbb6ccdf230e0911c42576e5148d53c1 @lorenzo lorenzo committed Feb 12, 2014
Showing with 15 additions and 14 deletions.
  1. +0 −9 src/Database/Driver/PDODriverTrait.php
  2. +15 −5 src/Database/Query.php
View
9 src/Database/Driver/PDODriverTrait.php
@@ -93,9 +93,6 @@ public function prepare($query) {
*/
public function beginTransaction() {
$this->connect();
- if ($this->_connection->inTransaction()) {
- return true;
- }
return $this->_connection->beginTransaction();
}
@@ -106,9 +103,6 @@ public function beginTransaction() {
*/
public function commitTransaction() {
$this->connect();
- if (!$this->_connection->inTransaction()) {
- return false;
- }
return $this->_connection->commit();
}
@@ -118,9 +112,6 @@ public function commitTransaction() {
* @return boolean true on success, false otherwise
*/
public function rollbackTransaction() {
- if (!$this->_connection->inTransaction()) {
- return false;
- }
return $this->_connection->rollback();
}
View
20 src/Database/Query.php
@@ -232,7 +232,21 @@ public function sql(ValueBinder $generator = null) {
$generator->resetCount();
}
- $visitor = function($parts, $name) use (&$sql, $generator) {
+ $query = $this->_transformQuery();
+ $query->traverse($query->_sqlCompiler($sql, $generator));
+ return $sql;
+ }
+
+/**
+ * Returns a callable object that can be used to compile a SQL string representtion
+ * of this query
+ *
+ * @param string $sql initial sql string to append to
+ * @param \Cake\Database\ValueBinder The placeholder and value binder object
+ * @return \Closure
+ */
+ protected function _sqlCompiler(&$sql, $generator) {
+ return function($parts, $name) use (&$sql, $generator) {
if (!count($parts)) {
return;
}
@@ -245,10 +259,6 @@ public function sql(ValueBinder $generator = null) {
}
return $sql .= $this->{'_build' . ucfirst($name) . 'Part'}($parts, $generator);
};
-
- $query = $this->_transformQuery();
- $query->traverse($visitor->bindTo($query));
- return $sql;
}
/**

0 comments on commit 3c4d9cc

Please sign in to comment.