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
2121This event is triggered whenever a new query has been run, whether successful or not. The only parameter is
2222a :doc: `Query </database/queries >` instance of the current query. You could use this to display all queries
2323in 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:
2527
2628.. literalinclude :: events/001.php
Original file line number Diff line number Diff line change 11<?php
22
33// 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