@@ 193-220 (lines=28) @@ | ||
190 | * |
|
191 | * @return void |
|
192 | */ |
|
193 | protected function listenQueryEvents() |
|
194 | { |
|
195 | // only Laravel versions below L5.2 supports `illuminate.query` |
|
196 | if ($this->detectLaravelVersion(['5.0', '5.1'])) |
|
197 | { |
|
198 | // $this->events->fire('illuminate.query', [$query, $bindings, $time, $this->getName()]); |
|
199 | $this->app['events']->listen('illuminate.query', function($query, $bindings, $time) |
|
200 | { |
|
201 | $this->app['understand.dataCollector']->setInArray('sql_queries', [ |
|
202 | 'query' => $query, |
|
203 | 'bindings' => $bindings, |
|
204 | 'time' => $time, |
|
205 | ]); |
|
206 | }); |
|
207 | } |
|
208 | else |
|
209 | { |
|
210 | // https://laravel.com/api/5.3/Illuminate/Database/Events/QueryExecuted.html |
|
211 | $this->app['events']->listen('Illuminate\Database\Events\QueryExecuted', function($event) |
|
212 | { |
|
213 | $this->app['understand.dataCollector']->setInArray('sql_queries', [ |
|
214 | 'query' => $event->sql, |
|
215 | 'bindings' => $event->bindings, |
|
216 | 'time' => $event->time, |
|
217 | ]); |
|
218 | }); |
|
219 | } |
|
220 | } |
|
221 | ||
222 | /** |
|
223 | * Handle a new log event |
@@ 201-227 (lines=27) @@ | ||
198 | * |
|
199 | * @return void |
|
200 | */ |
|
201 | protected function listenQueryEvents() |
|
202 | { |
|
203 | // only Lumen versions below L5.2 supports `illuminate.query` |
|
204 | if ($this->detectLumenVersion(['5.0', '5.1'])) |
|
205 | { |
|
206 | $this->app['events']->listen('illuminate.query', function($query, $bindings, $time) |
|
207 | { |
|
208 | $this->app['understand.dataCollector']->setInArray('sql_queries', [ |
|
209 | 'query' => $query, |
|
210 | 'bindings' => $bindings, |
|
211 | 'time' => $time, |
|
212 | ]); |
|
213 | }); |
|
214 | } |
|
215 | else |
|
216 | { |
|
217 | // https://laravel.com/api/5.3/Illuminate/Database/Events/QueryExecuted.html |
|
218 | $this->app['events']->listen('Illuminate\Database\Events\QueryExecuted', function($event) |
|
219 | { |
|
220 | $this->app['understand.dataCollector']->setInArray('sql_queries', [ |
|
221 | 'query' => $event->sql, |
|
222 | 'bindings' => $event->bindings, |
|
223 | 'time' => $event->time, |
|
224 | ]); |
|
225 | }); |
|
226 | } |
|
227 | } |
|
228 | ||
229 | /** |
|
230 | * Handle a new log event |