core:onAfterDatabaseQuery event
The core:onAfterDatabaseQuery event is triggered after a SQL query is executed by the database. This event is triggered only if theENABLE_DEVELOPER_TOOLS configuration option is enabled. The event handler should accept two parameters - the SQL query string and MySQL query result value. The result value depends on the query type and described in PHP documentation. Event handler example:
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);
}Next: shop:onDisplayOrdersPage event
Previous: cms:onExtendPartialForm event
Return to Handling LemonStand events

