Use SQL Data Sources

This example shows how to use the SQL data sources in the HTML Designer and Viewer. All SQL data are processed on the server side using PHP adapters. For their connection to the JavaScript side, the onBeginProcessData event is used. This event is triggered when the report engine requires data.

To send a request to the PHP server side and handle the response is sufficient to use the static StiHelper::createHandler() function which adds all necessary JavaScript code on a Web page:

designer.onBeginProcessData = function (event, callback) {
<?php StiHelper::createHandler(); ?>
}


If you need to change the data on the server side, for example, to correct the connection string or check the SQL query, you can use this event on the server side. Please correct the $handler->onBeginProcessData event in the handler.php file as you need:

$handler->onBeginProcessData = function ($event) {
$database = $event->database;
$connectionString = $event->connectionString;
$queryString = $event->queryString;
return StiResult::success();
};