EllisLab text mark
Advanced Search
     
log_message on DB Error
Posted: 23 August 2008 04:52 AM   [ Ignore ]
Joined: 2008-08-23
3 posts

Location: system/database/DB_driver.php
Method: query

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);
                return 
$this->display_error(
                                        array(
                                                
'Error Number: '.$error_no,
                                                
$error_msg,
                                                
$sql
                                            
)
                                        );
            

It looks like

log_message('error''Query error: '.$error_msg); 

should be outside of

if ($this->db_debug

since we still want to log an error even if debugging is off.

 
Posted: 20 February 2009 01:39 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Joined: 2008-12-09
10 posts

Hi,

I totally aggreed DB errors reporting are mandatory in a production env, despite full working queries an error can always occur. And generally you’d prefer having the cascading errors history to recover.

We’re discuting this point here too http://ellislab.com/forums/viewthread/91858/
I want to implement DB errors through the CI Exceptions (wich we can extend) handler to get emailed when mysql errors occured.