• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
db->queries and db->query_times sometimes do not correspond


please delete this thread. The question was made based on some confusion in my debugging.


I have adopted a large application that was written in CodeIgniter 1.7.

At every page load, it logs to file a combo of the entries that reside in $this->db->queries and $this->db->querytimes, like so:

if($this->db->queries) {
                foreach($this->db->queries as $key => $val) {
                    if($this->db->query_times[$key] >= 1) {
                        log_message('error', 'This database query took ' . round($this->db->query_times[$key],1) . ' seconds: ' . $val);

I get the impression that these two arrays were not meant to be read directly, as they are undocumented, but they do work most of the time.

However, sometimes, the final entry in $this->db->query_times has no corresponding entry in $this->db->queries. I know this because I do a print_r($this->db->query_times); print_r($this->db->queries);. This makes it impossible for me to find out which query string generated the stored query time. Unfortunately the slowest query in our app has corresponding query string stored in $this->db->queries.

Could this be a bug in CI ? Or am I (or my predecessor) wrongly assuming that $this->db->queries and $this->db->query_times are supposed to be corresponding arrays?

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.