Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added the ability to log queryes to logfile when db_debug is true

  • Loading branch information...
commit 75b9c05dd09dfc26afb43c6e5adc05e9d931ff5f 1 parent 6c94c2d
Rene Brokholm authored
View
23 system/database/DB_driver.php
@@ -483,8 +483,25 @@ public function simple_query($sql)
{
$this->initialize();
}
-
- return $this->_execute($sql);
+ $query = $this->_execute($sql);
+
+ if ($this->db_debug)
+ {
+ // Set log type
+ $log_type = 'DEBUG';
+ // Check if query failed
+ if ($this->_error_number())
+ {
+ // Change log type to error
+ $log_type = 'ERROR';
+ // Log query error message
+ log_message($log_type, 'Query error: (' . $this->_error_number() . ')' . $this->_error_message());
+ }
+ // Log the query
+ log_message($log_type, 'Query: ' . str_replace(array("\n", "\r"), " ", $sql));
+ }
+
+ return $query;
}
// --------------------------------------------------------------------
@@ -1564,4 +1581,4 @@ protected function _reset_select()
}
/* End of file DB_driver.php */
-/* Location: ./system/database/DB_driver.php */
+/* Location: ./system/database/DB_driver.php */
View
1  user_guide_src/source/changelog.rst
@@ -140,6 +140,7 @@ Release Date: Not Released
- Added PDO support for ``list_fields()`` in :doc:`Database Results <database/results>`.
- Added capability for packages to hold database.php config files
- Added subdrivers support (currently only used by PDO).
+ - Added query logging to DB_driver when the database config have $db['default']['db_debug']=TRUE;
- Libraries
Please sign in to comment.
Something went wrong with that request. Please try again.