summaryrefslogtreecommitdiffstats
path: root/system/libraries/Profiler.php
diff options
context:
space:
mode:
authorRick Ellis <rick.ellis@ellislab.com>2008-10-17 09:59:24 +0200
committerRick Ellis <rick.ellis@ellislab.com>2008-10-17 09:59:24 +0200
commit271e199ab8b33315a90b57eb447e9419c132c6dd (patch)
treeba6bc18934ad78aa17b11611ade1de3ee16fee5e /system/libraries/Profiler.php
parent73c3b118b12ad34069c4aa5dc2376b9ceaf4c969 (diff)
Added support for multiple database connections
Diffstat (limited to 'system/libraries/Profiler.php')
-rw-r--r--system/libraries/Profiler.php49
1 files changed, 34 insertions, 15 deletions
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 .= '<fieldset style="border:1px solid #0000FF;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
- $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 .= '<fieldset style="border:1px solid #0000FF;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
+ $output .= "\n";
$output .= '<legend style="color:#0000FF;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_queries').'&nbsp;&nbsp;</legend>';
$output .= "\n";
$output .= "\n\n<table cellpadding='4' cellspacing='1' border='0' width='100%'>\n";
$output .="<tr><td width='100%' style='color:#0000FF;font-weight:normal;background-color:#eee;'>".$this->CI->lang->line('profiler_no_db')."</td></tr>\n";
- }
- else
+ $output .= "</table>\n";
+ $output .= "</fieldset>";
+
+ return $output;
+ }
+
+ $output = "\n\n";
+
+ foreach ($dbs as $db)
{
- $output .= '<legend style="color:#0000FF;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_queries').' ('.count($this->CI->db->queries).')&nbsp;&nbsp;</legend>';
+ $output .= '<fieldset style="border:1px solid #0000FF;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
+ $output .= "\n";
+ $output .= '<legend style="color:#0000FF;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_database').':&nbsp; '.$db->database.'&nbsp;&nbsp;&nbsp;'.$this->CI->lang->line('profiler_queries').': '.count($this->CI->db->queries).'&nbsp;&nbsp;&nbsp;</legend>';
$output .= "\n";
$output .= "\n\n<table cellpadding='4' cellspacing='1' border='0' width='100%'>\n";
-
- if (count($this->CI->db->queries) == 0)
+
+ if (count($db->queries) == 0)
{
$output .= "<tr><td width='100%' style='color:#0000FF;font-weight:normal;background-color:#eee;'>".$this->CI->lang->line('profiler_no_queries')."</td></tr>\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 .= "<tr><td width='1%' valign='top' style='color:#990000;font-weight:normal;background-color:#ddd;'>".$time."&nbsp;&nbsp;</td><td style='color:#000;font-weight:normal;background-color:#ddd;'>".$val."</td></tr>\n";
}
}
+
+ $output .= "</table>\n";
+ $output .= "</fieldset>";
+
}
- $output .= "</table>\n";
- $output .= "</fieldset>";
-
return $output;
}