protected function _compile_queries()
{
$dbs = array();
$output = array();
// Let's determine which databases are currently connected to
foreach (get_object_vars($this->CI) as $CI_object) {
if (is_object($CI_object) && is_subclass_of(get_class($CI_object), 'CI_DB')) {
$dbs[] = $CI_object;
}
}
if (count($dbs) == 0) {
return $this->CI->lang->line('profiler_no_db');
}
// Load the text helper so we can highlight the SQL
$this->CI->load->helper('text');
// Key words we want bolded
$highlight = array('SELECT', 'DISTINCT', 'FROM', 'WHERE', 'AND', 'LEFT JOIN', 'ORDER BY', 'GROUP BY', 'LIMIT', 'INSERT', 'INTO', 'VALUES', 'UPDATE', 'OR ', 'HAVING', 'OFFSET', 'NOT IN', 'IN', 'LIKE', 'NOT LIKE', 'COUNT', 'MAX', 'MIN', 'ON', 'AS', 'AVG', 'SUM', '(', ')');
$total = 0;
// total query time
foreach ($dbs as $db) {
foreach ($db->queries as $key => $val) {
$time = number_format($db->query_times[$key], 4);
$total += $db->query_times[$key];
foreach ($highlight as $bold) {
$val = str_replace($bold, '<b>' . $bold . '</b>', $val);
}
$output[][$time] = $val;
}
}
if (count($output) == 0) {
$output = $this->CI->lang->line('profiler_no_queries');
} else {
$total = number_format($total, 4);
$output[][$total] = 'Total Query Execution Time';
}
return $output;
}