File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
user_guide_src/source/database Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,8 @@ DBQuery
21
21
This event is triggered whenever a new query has been run, whether successful or not. The only parameter is
22
22
a :doc: `Query </database/queries >` instance of the current query. You could use this to display all queries
23
23
in STDOUT, or logging to a file, or even creating tools to do automatic query analysis to help you spot
24
- potentially missing indexes, slow queries, etc. An example usage might be:
24
+ potentially missing indexes, slow queries, etc.
25
+
26
+ An example usage might be:
25
27
26
28
.. literalinclude :: events/001.php
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
3
// In app/Config/Events.php
4
- Events::on ('DBQuery ' , 'CodeIgniter\Debug\Toolbar\Collectors\Database::collect ' );
4
+
5
+ namespace Config ;
6
+
7
+ use CodeIgniter \Events \Events ;
8
+ use CodeIgniter \Exceptions \FrameworkException ;
9
+ use CodeIgniter \HotReloader \HotReloader ;
10
+
11
+ // ...
12
+
13
+ Events::on (
14
+ 'DBQuery ' ,
15
+ static function (\CodeIgniter \Database \Query $ query ) {
16
+ log_message ('info ' , (string ) $ query );
17
+ }
18
+ );
You can’t perform that action at this time.
0 commit comments