executeQuery()
Last updated 5/02/2024
The executeQuery()
is a function on the Five
object that is used to execute SQL statements on the Five server, and returns 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()
function will
use. However, if a new transaction is created via the startTransaction()
function, 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
parameter is not a Five transaction, the executeQuery()
function will expect the first parameter to be required which will be the query string or the query action ID.