@@ -169,17 +169,30 @@ protected function _compile_queries()
169169 $ output = array ();
170170
171171 // Let's determine which databases are currently connected to
172- foreach (get_object_vars ($ this ->CI ) as $ CI_object )
172+ foreach (get_object_vars ($ this ->CI ) as $ name => $ cobject )
173173 {
174- if (is_object ( $ CI_object ) && is_subclass_of ( get_class ( $ CI_object ), ' CI_DB ' ) )
174+ if ($ cobject )
175175 {
176- $ dbs [] = $ CI_object ;
176+ if ($ cobject instanceof CI_DB )
177+ {
178+ $ dbs [$ name ] = $ cobject ;
179+ }
180+ elseif ($ cobject instanceof CI_Model)
181+ {
182+ foreach (get_object_vars ($ cobject ) as $ mname => $ mobject )
183+ {
184+ if ($ mobject instanceof CI_DB )
185+ {
186+ $ dbs [$ mname ] = $ mobject ;
187+ }
188+ }
189+ }
177190 }
178191 }
179192
180193 if (count ($ dbs ) == 0 )
181194 {
182- return $ this ->CI ->lang ->line ('profiler_no_db ' );
195+ return $ this ->CI ->lang ->line ('profiler_no_db ' ); // to get db access must be public instance
183196 }
184197
185198 // Load the text helper so we can highlight the SQL
@@ -190,7 +203,7 @@ protected function _compile_queries()
190203
191204
192205 $ total = 0 ; // total query time
193- foreach ($ dbs as $ db )
206+ foreach ($ dbs as $ controler => $ db )
194207 {
195208
196209 foreach ($ db ->queries as $ key => $ val )
@@ -203,7 +216,7 @@ protected function _compile_queries()
203216 $ val = str_replace ($ bold , '<b> ' . $ bold .'</b> ' , $ val );
204217 }
205218
206- $ output [][$ time ] = $ val ;
219+ $ output [][$ time ] = $ controler . ' : ' . $ db -> database . ' ' . $ val ; // there's a filter CI plugin, so must show controler name, tho mention on wich controler was exec the query if some filter was applied
207220 }
208221
209222 }
@@ -220,8 +233,8 @@ protected function _compile_queries()
220233
221234 return $ output ;
222235 }
223-
224-
236+
237+
225238 // --------------------------------------------------------------------
226239
227240 /**
@@ -232,31 +245,34 @@ protected function _compile_queries()
232245 protected function _compile_eloquent ()
233246 {
234247 $ output = array ();
235-
248+
236249 // hack to make eloquent not throw error for now
237- $ this ->CI ->load ->model ('Eloquent/Assets/Action ' );
238-
239- if ( ! class_exists ('Illuminate\Database\Capsule\Manager ' )) {
250+ // but checks if file actually exists, or CI will throw an error
251+ if (file_exists (APPPATH .'/models/Eloquent/Assets/Action.php ' )) {
252+ $ this ->CI ->load ->model ('Eloquent/Assets/Action ' );
253+ }
254+
255+ if ( ! class_exists ('Illuminate\Database\Capsule\Manager ' , FALSE )) {
240256 $ output = 'Illuminate\Database has not been loaded. ' ;
241257 } else {
242258 // Load the text helper so we can highlight the SQL
243259 $ this ->CI ->load ->helper ('text ' );
244260
245261 // Key words we want bolded
246262 $ 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-
263+
264+
249265 $ total = 0 ; // total query time
250266 $ queries = Illuminate \Database \Capsule \Manager::getQueryLog ();
251267 foreach ($ queries as $ q )
252268 {
253269 $ time = number_format ($ q ['time ' ]/1000 , 4 );
254270 $ total += $ q ['time ' ]/1000 ;
255-
271+
256272 $ query = $ this ->interpolateQuery ($ q ['query ' ], $ q ['bindings ' ]);
257273 foreach ($ highlight as $ bold )
258274 $ query = str_ireplace ($ bold , '<b> ' .$ bold .'</b> ' , $ query );
259-
275+
260276 $ output [][$ time ] = $ query ;
261277 }
262278
@@ -405,7 +421,7 @@ protected function _compile_uri_string()
405421 */
406422 protected function _compile_controller_info ()
407423 {
408- $ output = $ this ->CI ->router ->fetch_class () ."/ " .$ this ->CI ->router ->fetch_method () ;
424+ $ output = $ this ->CI ->router ->class ."/ " .$ this ->CI ->router ->method ;
409425
410426 return $ output ;
411427 }
@@ -533,16 +549,19 @@ function _compile_userdata()
533549 {
534550 if (is_numeric ($ key ))
535551 {
536- $ output [$ key ] = " ' $ val' " ;
552+ $ output [$ key ] = print_r ( $ val, true ) ;
537553 }
538554
539555 if (is_array ($ val ) || is_object ($ val ))
540556 {
541- $ output [$ key ] = htmlspecialchars (stripslashes (print_r ($ val , true )));
557+ if (is_object ($ val ))
558+ $ output [$ key ] = json_decode (json_encode ($ val ), true );
559+ else
560+ $ output [$ key ] = htmlspecialchars (stripslashes (print_r ($ val , true )));
542561 }
543562 else
544563 {
545- $ output [$ key ] = htmlspecialchars (stripslashes ($ val ));
564+ $ output [$ key ] = htmlspecialchars (stripslashes (print_r ( $ val, true ) ));
546565 }
547566 }
548567 }
@@ -562,7 +581,7 @@ function _compile_userdata()
562581 */
563582 public function _compile_view_data ()
564583 {
565- $ output = '' ;
584+ $ output = array () ;
566585
567586 foreach ($ this ->_ci_cached_vars as $ key => $ val )
568587 {
0 commit comments