summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--system/database/DB_driver.php18
-rw-r--r--user_guide/changelog.html1
2 files changed, 19 insertions, 0 deletions
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index dfef42757..8e6f88801 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -1169,6 +1169,24 @@ class CI_DB_driver {
$message = ( ! is_array($error)) ? array(str_replace('%s', $swap, $LANG->line($error))) : $error;
}
+ // Find the most likely culprit of the error by going through
+ // the backtrace until the source file is no longer in the
+ // database folder.
+
+ $trace = debug_backtrace();
+
+ foreach($trace as $call)
+ {
+ if (isset($call['file']) && strpos($call['file'], BASEPATH.'database') === FALSE)
+ {
+ // Found it - use a relative path for safety
+ $message[] = 'Filename: '.str_replace(array(BASEPATH, APPPATH), '', $call['file']);
+ $message[] = 'Line Number: '.$call['line'];
+
+ break;
+ }
+ }
+
$error =& load_class('Exceptions', 'core');
echo $error->show_error($heading, $message, 'error_db');
exit;
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index 48d4309a5..38f84112d 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -110,6 +110,7 @@ Hg Tag: </p>
<li>Semantic change to db->version() function to allow a list of exceptions for databases with functions to return version string instead of specially formed SQL queries. Currently this list only includes Oracle and SQLite.</li>
<li>Fixed a bug where driver specific table identifier protection could lead to malformed queries in the <kbd>field_data()</kbd> functions.</li>
<li>Fixed a bug where an undefined class variable was referenced in database drivers.</li>
+ <li>Modified the database errors to show the filename and line number of the problematic query.</li>
<li>Removed the following deprecated functions: orwhere, orlike, groupby, orhaving, orderby, getwhere.</li>
<li>Removed deprecated _drop_database() and _create_database() functions from the db utility drivers.</li>
</ul>