GetRowsByTemplate
GetRowsByTemplate
method retrieves a number of rows returned by SQL query template. To use a template, it needs to be defined in ExpertSender web panel first. Template can be any valid SQL query that returns rows (SELECT
query). It is possible to create templates with parameters.
1. Method signature
rows = GetRowsByTemplate(template, parameters)
Parameter definition
Name | Type | Description |
---|---|---|
template | string | Required. Template name. |
parameters | array of Param objects | Optional. Array of objects defining template parameters. Can be omitted if template has no parameters. |
rows | array of rows | Return value. Array of rows. Every row itself is an array of key-value pairs (column name => column value). Column name is string. Column value type depends on actual type in the database. Array is empty if no data was found. Rows table can be enumerated upon, e.g. to display in form of HTML table. See examples for more information. |
Param
object parameter definition
Name | Type | Description |
---|---|---|
Name | string | Parameter name. |
Value | object | Parameter value. Value type depends on defined parameter type. |
NOTE: typically, Param
objects are created using constructor, which is more convenient. See examples for more information.
2. Using GetRowsByTemplate method
Example — simple request using template with two parameters:
GetRowsByTemplate('MyTemplate', new [] {new Param('numberParam', 123), new Param('textParam', 'abc')})
Returned output is the same as with regular GetRows method. You may enumerate rows, access rows and columns by indexes etc. Please see GetRows documentation for more details.