Created
May 27, 2014 13:06
-
-
Save Anahkiasen/6ae7f2904f1dc1febfa9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Transform a Query object to its SQL value | |
* | |
* @param Query $query | |
* | |
* @return string | |
*/ | |
function queryToSql($query) | |
{ | |
// Unnest query objects | |
while (method_exists($query, 'getQuery')) { | |
$query = $query->getQuery(); | |
} | |
// Replace bindings | |
$sql = str_replace('?', '%s', $query->toSql()); | |
$sql = vsprintf($sql, $query->getBindings()); | |
return $sql; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment