Skip to content

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

NameTypeDescription
templatestringRequired. Template name.
parametersarray of Param objectsOptional. Array of objects defining template parameters. Can be omitted if template has no parameters.
rowsarray of rowsReturn 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

NameTypeDescription
NamestringParameter name.
ValueobjectParameter 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.

On this page
To top