Query
The Query component contains information about a query to be performed against a database.
Contents
Usage
Configuration
To get your Query component working, you need to configure these properties: Active, Database, and SQL.
Parametrized Queries
Note: The is a sample application covering parametrized queries in the sample applications folder, under Data Aware\query.
Parametrized Queries are SQL sentences with placeholders for data to be later included by the Query component. They improve performance in intense query processes.
First, add parameters to a Query component. Use the Database::Param() method to format those parameters:
$this->Query1->Filter=" products_date_added>=".$this->Database1->Param('start_date').
" and products_date_added<=".$this->Database1->Param('end_date')."";
The resulting SQL query will then have placeholders instead of the actual values. Conceptually, something like this:
SELECT * FROM products WHERE products_date_added>='?' and products_date_added<='?'
Then, to setup the values that will replace the placeholders when performing the actual query, use the Params property of the Query component, which is an array with parameters and their values.
Note: Be careful, they must be placed in the array in the same order they appear in the SQL sentence.
$params=array();
$params[]=$this->dtStart->Text;
$params[]=$this->dtEnd->Text;
$this->Query1->Params=$params;
Now that you setup the values for the parameters, you must prepare the query with the Query::Prepare() method.
$this->Query1->Prepare();
Server-side Features
Properties, Methods and Events
- Documented in the RPCL Reference.
Help Resources
Sample Applications
In the following folders inside the sample applications directory you will find projects covering this component: