-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8229 from kenjis/docs-db-event-sample
docs: change sample code in DB Events
- Loading branch information
Showing
2 changed files
with
18 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,18 @@ | ||
<?php | ||
|
||
// In app/Config/Events.php | ||
Events::on('DBQuery', 'CodeIgniter\Debug\Toolbar\Collectors\Database::collect'); | ||
|
||
namespace Config; | ||
|
||
use CodeIgniter\Events\Events; | ||
use CodeIgniter\Exceptions\FrameworkException; | ||
use CodeIgniter\HotReloader\HotReloader; | ||
|
||
// ... | ||
|
||
Events::on( | ||
'DBQuery', | ||
static function (\CodeIgniter\Database\Query $query) { | ||
log_message('info', (string) $query); | ||
} | ||
); |