/
Querying Data

Querying Data

query

Execute read-only SQL query on the database.

array query(string $sql, array $bind_parameters)

Parameters

$sql The query string. All data inside the query should be bound with named bind variables or properly escaped.
$bind_parameters An array of key-value pairs with elements that are bound parameters in the SQL statement being executed. Array key names match the named bind variables in the SQL statement.

Return Values

Returns FALSE on failure. For successful queries, it will return an array of data.

getQueryError

Retrieve the last Query Error that was triggered by the query function. When executing invalid SQL the query function returns false. To see the error in the query use this function.

string getQueryError()

Example: Simple Services Query

$services = $this->query("SELECT * FROM SERVICES");

Example: Using Heredoc Notation

This example uses PHP heredoc Notation to query for Available Services

Example: Using Bind Variables

This example uses Bind Variables to query for Services with specified (Active and Available) Status Codes. Data can be bound to the query as arrays or single variables.

Example: Retrieving Query Error

This example executes a bad SQL statement and then retrieves the error and sends it to the debug function.

Related content

Creating Inbound/Outbound Files
Creating Inbound/Outbound Files
Read with this
(2024.2) Querying Data
(2024.2) Querying Data
More like this
Sending a System Message
Sending a System Message
Read with this
Retrieving List Values
Retrieving List Values
More like this
Callable Functions
Callable Functions
Read with this
(2024.2) Retrieving List Values
(2024.2) Retrieving List Values
More like this