LemonStand Documentation

core:onBeforeDatabaseQuery event

The core:onBeforeDatabaseQuery event is triggered before a SQL query is sent to the database. This event is triggered only if the ENABLE_DEVELOPER_TOOLS configuration option is enabled. The event handler should accept a single parameter - the SQL query string. 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: cms:onExtendPartialForm event
Previous: core:onProcessImage event
Return to Handling LemonStand events