From 271e199ab8b33315a90b57eb447e9419c132c6dd Mon Sep 17 00:00:00 2001 From: Rick Ellis Date: Fri, 17 Oct 2008 07:59:24 +0000 Subject: Added support for multiple database connections --- system/libraries/Profiler.php | 49 ++++++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 15 deletions(-) (limited to 'system/libraries/Profiler.php') diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php index 13cb1ccaa..669662e63 100644 --- a/system/libraries/Profiler.php +++ b/system/libraries/Profiler.php @@ -102,24 +102,41 @@ class CI_Profiler { */ function _compile_queries() { - $output = "\n\n"; - $output .= '
'; - $output .= "\n"; - - if ( ! class_exists('CI_DB_driver')) + // Let's determine which databases are currently connected to + foreach (get_object_vars($this->CI) as $CI_object) + { + if ( is_subclass_of(get_class($CI_object), 'CI_DB') ) + { + $dbs[] = $CI_object; + } + } + + if (count($dbs) == 0) { + $output = "\n\n"; + $output .= '
'; + $output .= "\n"; $output .= '  '.$this->CI->lang->line('profiler_queries').'  '; $output .= "\n"; $output .= "\n\n\n"; $output .="\n"; - } - else + $output .= "
".$this->CI->lang->line('profiler_no_db')."
\n"; + $output .= "
"; + + return $output; + } + + $output = "\n\n"; + + foreach ($dbs as $db) { - $output .= '  '.$this->CI->lang->line('profiler_queries').' ('.count($this->CI->db->queries).')  '; + $output .= '
'; + $output .= "\n"; + $output .= '  '.$this->CI->lang->line('profiler_database').':  '.$db->database.'   '.$this->CI->lang->line('profiler_queries').': '.count($this->CI->db->queries).'   '; $output .= "\n"; $output .= "\n\n\n"; - - if (count($this->CI->db->queries) == 0) + + if (count($db->queries) == 0) { $output .= "\n"; } @@ -127,10 +144,11 @@ class CI_Profiler { { $highlight = array('SELECT', 'FROM', 'WHERE', 'AND', 'LEFT JOIN', 'ORDER BY', 'LIMIT', 'INSERT', 'INTO', 'VALUES', 'UPDATE', 'OR'); - foreach ($this->CI->db->queries as $key => $val) + foreach ($db->queries as $key => $val) { $val = htmlspecialchars($val, ENT_QUOTES); - $time = number_format($this->CI->db->query_times[$key], 4); + + $time = number_format($db->query_times[$key], 4); foreach ($highlight as $bold) { @@ -140,11 +158,12 @@ class CI_Profiler { $output .= "\n"; } } + + $output .= "
".$this->CI->lang->line('profiler_no_queries')."
".$time."  ".$val."
\n"; + $output .= "
"; + } - $output .= "\n"; - $output .= "
"; - return $output; } -- cgit v1.2.3-24-g4f1b