Added backtrace comment to SQL queries

Just a dump of the data from debug_backtrace in reverse order, Class:Line#

Closes #4
This commit is contained in:
Josh Sherman 2012-10-11 09:51:01 -04:00
parent 9fbc4171d7
commit 9eb2d438a8
2 changed files with 28 additions and 6 deletions

View file

@ -151,13 +151,24 @@ class Database_PDO_Common extends Database_Common
// Checks if the query is blank
if ($sql != '')
{
$files = array();
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
krsort($backtrace);
foreach ($backtrace as $file)
{
$files[] = $file['class'] . ':' . $file['line'];
}
$sql .= "\n" . '/* [' . implode('|', $files) . '] */';
try
{
// Establishes if we're working on an EXPLAIN
if (Profiler::enabled('explains') == true)
{
$explaining = preg_match('/^EXPLAIN /i', $sql);
$selecting = preg_match('/^SELECT /i', $sql);
$selecting = preg_match('/^SELECT /i', $sql);
}
else
{
@ -174,7 +185,7 @@ class Database_PDO_Common extends Database_Common
$explain = $this->fetch('EXPLAIN ' . $sql);
}
$start_time = microtime(true);
$start_time = microtime(true);
$this->results = $this->connection->query($sql);
}
// Executes a prepared statement
@ -186,7 +197,7 @@ class Database_PDO_Common extends Database_Common
$explain = $this->fetch('EXPLAIN ' . $sql, $input_parameters);
}
$start_time = microtime(true);
$start_time = microtime(true);
$this->results = $this->connection->prepare($sql);
$this->results->execute($input_parameters);
}