From d2018ee8ae967cafbd8315ba9ea45f58150bcffe Mon Sep 17 00:00:00 2001 From: Niklas Nilsson Date: Tue, 30 Aug 2011 13:39:42 +0200 Subject: Fixed issue #105 SQL log errors Enabled logging database query errors even if $db_debug is not enabled. --- system/database/DB_driver.php | 19 +++++++++++-------- user_guide/changelog.html | 1 + 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index f3e824daa..300ca2977 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -251,9 +251,10 @@ class CI_DB_driver { { if ($sql == '') { + log_message('error', 'Invalid query: '.$sql); + if ($this->db_debug) { - log_message('error', 'Invalid query: '.$sql); return $this->display_error('db_invalid_query'); } return FALSE; @@ -306,21 +307,23 @@ class CI_DB_driver { // This will trigger a rollback if transactions are being used $this->_trans_status = FALSE; + // Grab the error number and message now, as we might run some + // additional queries before displaying the error + $error_no = $this->_error_number(); + $error_msg = $this->_error_message(); + + // Log errors + log_message('error', 'Query error: '.$error_msg); + if ($this->db_debug) { - // grab the error number and message now, as we might run some - // additional queries before displaying the error - $error_no = $this->_error_number(); - $error_msg = $this->_error_message(); - // We call this function in order to roll-back queries // if transactions are enabled. If we don't call this here // the error message will trigger an exit, causing the // transactions to remain in limbo. $this->trans_complete(); - // Log and display errors - log_message('error', 'Query error: '.$error_msg); + // Display errors return $this->display_error( array( 'Error Number: '.$error_no, diff --git a/user_guide/changelog.html b/user_guide/changelog.html index 978b710be..b3a58617e 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -112,6 +112,7 @@ Change Log
  • Fixed a bug (Reactor #19) where 1) the 404_override route was being ignored in some cases, and 2) auto-loaded libraries were not available to the 404_override controller when a controller existed but the requested method did not.
  • Fixed a bug (Reactor #89) where MySQL export would fail if the table had hyphens or other non alphanumeric/underscore characters.
  • Fixed a bug (#200) where MySQL queries would be malformed after calling count_all() then db->get()
  • +
  • Fixed bug #105 that stopped query errors from being logged unless database debugging was enabled
  • Fixed a bug (#181) where a mis-spelling was in the form validation language file.
  • Fixed a bug (#160) - Removed unneeded array copy in the file cache driver.
  • Fixed a bug (#150) - field_data() now correctly returns column length.
  • -- cgit v1.2.3-24-g4f1b