@@ -15,6 +15,14 @@ class Profiler_Profiler {
1515 * @var array
1616 */
1717 public $ config = array ();
18+
19+ /**
20+ * The list of query types we care about for type specific stats
21+ *
22+ * @var array
23+ *
24+ */
25+ protected $ _queryTypes = array ('select ' , 'update ' , 'delete ' , 'insert ' );
1826
1927 /**
2028 * Sets the configuration options for this object and sets the start time.
@@ -148,10 +156,11 @@ public function gatherQueryData() {
148156 'time ' => ($ log ['end_time ' ] - $ log ['start_time ' ]),
149157 'duplicate ' => $ i > 0 ? true : false );
150158
151- // Lets figure out the type of query for our countes
159+ // Lets figure out the type of query for our counts
152160 $ trimmed = trim ($ log ['sql ' ]);
153161 $ type = strtolower (substr ($ trimmed , 0 , strpos ($ trimmed , ' ' )));
154- if (isset ($ queryTotals ['types ' ][$ type ])) {
162+
163+ if (isset ($ this ->_queryTypes [$ type ]) && isset ($ queryTotals ['types ' ][$ type ])) {
155164 $ queryTotals ['types ' ][$ type ]['total ' ] += 1 ;
156165 $ queryTotals ['types ' ][$ type ]['time ' ] += $ query ['time ' ];
157166 }
@@ -162,7 +171,10 @@ public function gatherQueryData() {
162171 $ query ['time ' ] = $ this ->getReadableTime ($ query ['time ' ]);
163172
164173 // If an explain callback is setup try to get the explain data
165- if (isset ($ this ->config ['query_explain_callback ' ]) && !empty ($ this ->config ['query_explain_callback ' ])) {
174+ if (isset ($ this ->_queryTypes [$ type ])
175+ && isset ($ this ->config ['query_explain_callback ' ])
176+ && !empty ($ this ->config ['query_explain_callback ' ])) {
177+
166178 $ query ['explain ' ] = $ this ->_attemptToExplainQuery ($ query ['sql ' ]);
167179 }
168180
0 commit comments