Part of the EllisLab Network
   
 
logging database queries
Posted: 30 June 2007 05:23 AM   [ Ignore ]  
Summer Student
Total Posts:  7
Joined  01-05-2007

Been looking at db_debug and stuff like that, but I don’t find and obvious way to log all database queries to a file.
In fact I wan’t only to log any query that modifies the database.

Any suggestions on how to achieve this?

All my application code uses actice record so I was thinking of extending that class, so the methods that imply update, insert, delete would log the SQL query automtically. But since the active record class is not a library, I don’t believe I can extend it in the application/libraries folder the standard way.
How can I avoid modifying the CodeIgniter source and still achieve this?
An I don’t want to rely on manualy adding logging statements in the controller code itself.

Profile
 
 
Posted: 30 June 2007 12:21 PM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  352
Joined  04-27-2006

just a suggestion:
the profiler class shows all your queries if you want…
you could check, how it is done and copy and modify the profiler library to your purpose so it´s logging the query instead of displaying it…
and make it a post controller hook…
what a great idea…  smile

Profile
 
 
Posted: 01 July 2007 01:14 AM   [ Ignore ]   [ # 2 ]  
Summer Student
Total Posts:  14
Joined  03-18-2007

Look at Profiler library code.

if (class_exists('CI_DB_driver'))
{
  
foreach ($this->CI->db->queries as $val)
  
{
  }
}

Look at DB_Driver code.

$this->queries[] = $sql;

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 719, on June 06, 2008 10:16 AM
Total Registered Members: 64453 Total Logged-in Users: 25
Total Topics: 80959 Total Anonymous Users: 1
Total Replies: 435689 Total Guests: 191
Total Posts: 516648    
Members ( View Memberlist )