Skip to content

Commit

Permalink
Not using bindTo(), it is not implemented in hhvm
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Feb 13, 2014
1 parent 635757a commit 3c4d9cc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
9 changes: 0 additions & 9 deletions src/Database/Driver/PDODriverTrait.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ public function prepare($query) {
*/ */
public function beginTransaction() { public function beginTransaction() {
$this->connect(); $this->connect();
if ($this->_connection->inTransaction()) {
return true;
}
return $this->_connection->beginTransaction(); return $this->_connection->beginTransaction();
} }


Expand All @@ -106,9 +103,6 @@ public function beginTransaction() {
*/ */
public function commitTransaction() { public function commitTransaction() {
$this->connect(); $this->connect();
if (!$this->_connection->inTransaction()) {
return false;
}
return $this->_connection->commit(); return $this->_connection->commit();
} }


Expand All @@ -118,9 +112,6 @@ public function commitTransaction() {
* @return boolean true on success, false otherwise * @return boolean true on success, false otherwise
*/ */
public function rollbackTransaction() { public function rollbackTransaction() {
if (!$this->_connection->inTransaction()) {
return false;
}
return $this->_connection->rollback(); return $this->_connection->rollback();
} }


Expand Down
20 changes: 15 additions & 5 deletions src/Database/Query.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -232,7 +232,21 @@ public function sql(ValueBinder $generator = null) {
$generator->resetCount(); $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)) { if (!count($parts)) {
return; return;
} }
Expand All @@ -245,10 +259,6 @@ public function sql(ValueBinder $generator = null) {
} }
return $sql .= $this->{'_build' . ucfirst($name) . 'Part'}($parts, $generator); return $sql .= $this->{'_build' . ucfirst($name) . 'Part'}($parts, $generator);
}; };

$query = $this->_transformQuery();
$query->traverse($visitor->bindTo($query));
return $sql;
} }


/** /**
Expand Down

0 comments on commit 3c4d9cc

Please sign in to comment.