Skip to content
This repository has been archived by the owner on Nov 26, 2020. It is now read-only.

Commit

Permalink
Fixed issue bcit-ci#105 SQL log errors
Browse files Browse the repository at this point in the history
Enabled logging database query errors even if $db_debug is not enabled.
  • Loading branch information
splitfeed committed Aug 30, 2011
1 parent b50df5f commit d2018ee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
19 changes: 11 additions & 8 deletions system/database/DB_driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,10 @@ function query($sql, $binds = FALSE, $return_object = TRUE)
{
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;
Expand Down Expand Up @@ -306,21 +307,23 @@ function query($sql, $binds = FALSE, $return_object = TRUE)
// 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,
Expand Down
1 change: 1 addition & 0 deletions user_guide/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ <h3>Bug fixes for 2.1.0</h3>
<li class="reactor">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.</li>
<li class="rector">Fixed a bug (Reactor #89) where MySQL export would fail if the table had hyphens or other non alphanumeric/underscore characters.</li>
<li class="reactor">Fixed a bug (#200) where MySQL queries would be malformed after calling <samp>count_all()</samp> then <samp>db->get()</samp></li>
<li class="reactor">Fixed bug #105 that stopped query errors from being logged unless database debugging was enabled</li>
<li>Fixed a bug (#181) where a mis-spelling was in the form validation language file.</li>
<li>Fixed a bug (#160) - Removed unneeded array copy in the file cache driver.</li>
<li>Fixed a bug (#150) - <samp>field_data()</samp> now correctly returns column length.</li>
Expand Down

0 comments on commit d2018ee

Please sign in to comment.