[eluser]WanWizard[/eluser]
The initialize() method is called before running a query in the simple_query() method:
Code:
if ( ! $this->conn_id)
{
$this->initialize();
}
If some other/external event has closed the connection to your database (for whatever reason), CI is not aware of this unless this event has called $this->db->close().
My guess is therefore that $this->conn_id doesn't evaluate to false, so the initialize() method isn't even called. You only get an error when you try to execute your query, and the query library used detects that the resource that is stored in $this->conn_id when the database connection is made by CI is no longer valid.
Since you can not extend DB_driver, maybe modifying the code to:
Code:
if ( ! $this->conn_id OR ! is_resource( $this->conn_id) )
{
$this->conn_id = FALSE;
$this->initialize();
}
will fix it.
edit: probably not. It will still be a resource as far as PHP is concerned, the first database call that tries to use it will throw an error.
The best way off course is to prevent this race condition from happening, and make sure none of your code closes the database connection. It's an indication of bad coding practice, housekeeping should be at the end of script execution.