From 56e9fa581b9e7d590dfb56482b898339f29bd8f2 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Wed, 23 Jan 2008 17:26:37 +0000 Subject: added $query_times property to DB driver for profiling added individual query execution time to profiler output --- system/libraries/Profiler.php | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php index 3b189027f..21c2135cc 100644 --- a/system/libraries/Profiler.php +++ b/system/libraries/Profiler.php @@ -105,34 +105,49 @@ class CI_Profiler { $output = "\n\n"; $output .= '
'; $output .= "\n"; - $output .= '  '.$this->CI->lang->line('profiler_queries').'  '; - $output .= "\n"; if ( ! class_exists('CI_DB_driver')) { - $output .= "
".$this->CI->lang->line('profiler_no_db')."
"; + $output .= '  '.$this->CI->lang->line('profiler_queries').'  '; + $output .= "\n"; + $output .= "\n\n\n"; + $output .="\n"; } else { + $output .= '  '.$this->CI->lang->line('profiler_queries').' ('.count($this->CI->db->queries).')  '; + $output .= "\n"; + $output .= "\n\n
".$this->CI->lang->line('profiler_no_db')."
\n"; + if (count($this->CI->db->queries) == 0) { - $output .= "
".$this->CI->lang->line('profiler_no_queries')."
"; + $output .= "\n"; } else { - foreach ($this->CI->db->queries as $val) + $highlight = array('SELECT', 'FROM', 'WHERE', 'AND', 'OR', 'LEFT JOIN', 'ORDER BY', 'LIMIT', 'INSERT', 'INTO', 'VALUES', 'UPDATE'); + + foreach ($this->CI->db->queries as $key => $val) { - $output .= '
'; - $output .= htmlspecialchars($val, ENT_QUOTES); - $output .= "
\n"; - } + $val = htmlspecialchars($val, ENT_QUOTES); + $time = number_format($this->CI->db->query_times[$key], 4); + + foreach ($highlight as $bold) + { + $val = str_replace($bold, ''.$bold.'', $val); + } + + $output .= "\n"; + } } } - $output .= ""; + $output .= "
".$this->CI->lang->line('profiler_no_queries')."
".$time."  ".$val."
\n"; + $output .= "
"; return $output; } + // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b