Skip to content

Instantly share code, notes, and snippets.

@hugowetterberg
Created October 14, 2009 12:22
Show Gist options
  • Save hugowetterberg/210021 to your computer and use it in GitHub Desktop.
Save hugowetterberg/210021 to your computer and use it in GitHub Desktop.
<?php
function db_query_debug($sql, $parameters) {
global $db_prefix;
$sql = preg_replace('/\{([^\}]+)\}/', $db_prefix . '$1', $sql);
if (!is_array($parameters)) {
$parameters = array_slice(func_get_args(), 1);
}
$args = array_merge(array($sql), $parameters);
$q = call_user_func_array('sprintf', $args);
return $q;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment