Page 1 of 1
Send query for variable
Posted: Wed Apr 08, 2020 12:53 am
by eduardo12fox
Hello Guys,
I would like send my query done for variable in report PHP. I can build dinamically my query in page php and send for parameter for viewer. But when I create the variable in design and try do. I get a report blank withoud nothing into.
Help me please
Re: Send query for variable
Posted: Fri Apr 10, 2020 11:35 am
by Lech Kulikowski
Hello,
You can set it in the onBeginProcessData event on the server side in the handler.php
Code: Select all
$handler->onBeginProcessData = function ($event) {
// Current database type: 'XML', 'JSON', 'MySQL', 'MS SQL', 'PostgreSQL', 'Firebird', 'Oracle'
$database = $event->database;
// Current connection name
$connection = $event->connection;
// Current data source name
$dataSource = $event->dataSource;
// Connection string for the current data source
$connectionString = $event->connectionString;
// SQL query string for the current data source
$queryString = $event->queryString;
// You can change the connection string
//if ($connection == "MyConnectionName")
// $event->connectionString = "Server=localhost;Database=test;Port=3306;";
// You can change the SQL query
//if ($dataSource == "MyDataSource")
// $event->queryString = "SELECT * FROM MyTable";
// You can replace the SQL query parameters with the required values
// For example: SELECT * FROM {Variable1} WHERE Id={Variable2}
// If the report contains a variable with this name, its value will be used instead of the specified value
//$event->parameters["Variable1"] = "TableName";
//$event->parameters["Variable2"] = 10;
return StiResult::success();
//return StiResult::error("Message for some connection error.");
};
Thank you.