Triggered before a SQL query is sent to the database.
public function subscribeEvents()
{
Backend::$events->addEvent('core:onBeforeDatabaseQuery', $this, 'on_before_query');
Backend::$events->addEvent('core:onAfterDatabaseQuery', $this, 'on_after_query');
}
public function on_before_query($sql)
{
// Start timing for the query
Phpr_DebugHelper::start_timing($sql);
}
public function on_after_query($sql, $result)
{
// Stop timing and write the result to the trace log (logs/info.txt)
Phpr_DebugHelper::end_timing($sql);
}