protected function _compile_eloquent()
{
$output = array();
// hack to make eloquent not throw error for now
// but checks if file actually exists, or CI will throw an error
if (file_exists(APPPATH . '/models/Eloquent/Assets/Action.php')) {
$this->CI->load->model('Eloquent/Assets/Action');
}
if (!class_exists('Illuminate\\Database\\Capsule\\Manager')) {
$output = 'Illuminate\\Database has not been loaded.';
} else {
// 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
$queries = Illuminate\Database\Capsule\Manager::getQueryLog();
foreach ($queries as $q) {
$time = number_format($q['time'] / 1000, 4);
$total += $q['time'] / 1000;
$query = $this->interpolateQuery($q['query'], $q['bindings']);
foreach ($highlight as $bold) {
$query = str_ireplace($bold, '<b>' . $bold . '</b>', $query);
}
$output[][$time] = $query;
}
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;
}