executeQuery()
Last updated 13/07/2022
The executeQuery()
is a function that is used to execute SQL statements on the Five server, and return the results. You can use executeQuery()
to perform SELECT
, UPDATE
,
and DELETE
operations on the database.
Available
Server
executeQuery([Transaction,] Query[, Limit[, Parameters...]]) : QueryResult;
Parameter | Type | Default | Description |
---|---|---|---|
Transaction | transaction object | null | Transaction is optional and when not supplied null is the default. |
Query | string | null | Query to be executed. |
Limit | number | 0 | Maximum number of rows to return. |
Parameters | variable | Parameters for the query. |
When working with Five, by default Five will create a transaction at the start of a CREATE
, UPDATE
, DELETE
operation to the application's database which theexecuteQuery()
will
use. However, if a new transaction is created via the five.startTransaction()
, this can be passed in as the first parameter, and the executeQuery()
will use this transaction instead.
Query
is a string of an SQL statement or the Action ID of a saved query in your application.
Limit
will limit how many rows are returned from the query. The default is 0 and this will result in Five returning all the result rows for the query. Limit
is normally
optional, however, if supplying parameters, Limit
is required. The parameters after Limit
will be passed as arguments to the query.
If the optional Transaction
argument is not a Five transaction, the executeQuery()
will expect the first parameter to be required which will be the query string or the query Action ID.