Skip to content

Instantly share code, notes, and snippets.

@GDmac
Last active December 29, 2015 15:19
Show Gist options
  • Save GDmac/7689850 to your computer and use it in GitHub Desktop.
Save GDmac/7689850 to your computer and use it in GitHub Desktop.
Codeigniter profiler, where are the queries coming from ?
// ...
// Save the query for debugging
if ($this->save_queries == TRUE)
{
// ADDED: Some backtracing
$file = '';
$callstack = debug_backtrace();
if(count($callstack) >= 2)
{
//list($callee) = $callstack[1];
if (strpos($callstack[1]['file'], BASEPATH)===0)
{
$file = 'CI/'.str_replace(BASEPATH, '', $callstack[1]['file']);
}
elseif (strpos($callstack[1]['file'], APPPATH)===0)
{
$file = 'APP/'.str_replace(APPPATH, '', $callstack[1]['file']);
}
else
{
$file = 'UNKNOWN : '.$callstack[1]['file'];
}
$file = "\n#" . $file;
}
$this->queries[] = $sql . $file;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment