Skip to content

Commit 04e983c

Browse files
authored
Merge pull request lonnieezell#26 from waldirbertazzijr/master
If no eloquent models are installed, checks if the file actually exists
2 parents 2a680ed + 0a75d69 commit 04e983c

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

libraries/Profiler.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ protected function _compile_queries()
220220

221221
return $output;
222222
}
223-
224-
223+
224+
225225
// --------------------------------------------------------------------
226226

227227
/**
@@ -232,10 +232,13 @@ protected function _compile_queries()
232232
protected function _compile_eloquent()
233233
{
234234
$output = array();
235-
235+
236236
// hack to make eloquent not throw error for now
237-
$this->CI->load->model('Eloquent/Assets/Action');
238-
237+
// but checks if file actually exists, or CI will throw an error
238+
if (file_exists(APPPATH.'/models/Eloquent/Assets/Action.php')) {
239+
$this->CI->load->model('Eloquent/Assets/Action');
240+
}
241+
239242
if ( ! class_exists('Illuminate\Database\Capsule\Manager')) {
240243
$output = 'Illuminate\Database has not been loaded.';
241244
} else {
@@ -244,19 +247,19 @@ protected function _compile_eloquent()
244247

245248
// Key words we want bolded
246249
$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', '(', ')');
247-
248-
250+
251+
249252
$total = 0; // total query time
250253
$queries = Illuminate\Database\Capsule\Manager::getQueryLog();
251254
foreach ($queries as $q)
252255
{
253256
$time = number_format($q['time']/1000, 4);
254257
$total += $q['time']/1000;
255-
258+
256259
$query = $this->interpolateQuery($q['query'], $q['bindings']);
257260
foreach ($highlight as $bold)
258261
$query = str_ireplace($bold, '<b>'.$bold.'</b>', $query);
259-
262+
260263
$output[][$time] = $query;
261264
}
262265

0 commit comments

Comments
 (0)