| Methods |
public
|
__construct(string $endpoint, array|int $parameters = [], API|null $api = null)
Create and run a new query.
Create and run a new query.
Parameters
| $endpoint |
The CultureHosts endpoint to use, e.g. events
|
| $parameters |
Either a CultureHosts record ID or an array of arguments in key value pairs
|
| $api |
The API object to use. Leave as null to use the global default.
|
Throws
|
#
|
public
|
get_api(): API|null
Get the API object this Query is using
Get the API object this Query is using
|
#
|
public
|
has_records(): boolean
Whether the remote API returned any records.
Whether the remote API returned any records.
|
#
|
public
|
is_error(): boolean
Whether this query produced an error.
Whether this query produced an error.
|
#
|
public
|
get_error_message(): string|null
Get the error message received from the remote API, if any.
Get the error message received from the remote API, if any.
|
#
|
public
|
get_validation_error_messages(): string[]
Get any validation errors that the API responded with. For example, if you passed an invalid parameter value to the API, a validation
error would be returned an is retrievable with this method.
Get any validation errors that the API responded with. For example, if you passed an invalid parameter value to the API, a validation
error would be returned an is retrievable with this method.
Returns
Empty if no errors occurred
|
#
|
public
|
get_records(): Record[]
Get all of the records resulting from this query as an array.
Get all of the records resulting from this query as an array.
|
#
|
public
|
get_record(integer $index = 0): Record|null
Get a specific record from the result set.
Get a specific record from the result set.
Parameters
| $index |
The index (starting at 0) of the record to fetch.
|
|
#
|
public
|
get_meta(string $key): mixed
Get details about the result set returned, e.g. pagination details and totals.
Get details about the result set returned, e.g. pagination details and totals.
Parameters
| $key |
One of current_page, from, last_page, per_page, to, total
|
Returns
The value returned by the API
|
#
|
public
|
get_link(string $key): mixed
Get details about the other result sets available, e.g. pagination details. These are more useful for users of the raw API than those using this request wrapper.
Get details about the other result sets available, e.g. pagination details. These are more useful for users of the raw API than those using this request wrapper.
Parameters
| $key |
One of first, last, prev, next
|
|
#
|
public
|
getIterator(): Traversable
Query objects act as an ItteratorAggregate, so you can use them in loops or otherwise iterate
over the records they contain.
Query objects act as an ItteratorAggregate, so you can use them in loops or otherwise iterate
over the records they contain.
Implements
|
#
|
| Properties |
public
readonly
|
int
|
$status_code
The HTTP status code from the API response
The HTTP status code from the API response
|
#
|
public
readonly
|
bool
|
$is_error
Whether the API response was an error
Whether the API response was an error
|
#
|
public
readonly
|
int
|
$error_message
The error message from the API response
The error message from the API response
|
#
|
public
readonly
|
array
|
$validation_error_messages
Any validation error messages from the API response
Any validation error messages from the API response
|
#
|
public
readonly
|
string
|
$endpoint
The CultureHosts endpoint used, e.g. events
The CultureHosts endpoint used, e.g. events
|
#
|
public
readonly
|
array|int
|
$parameters
The parameters used. Either a CultureHosts record ID or an array of arguments in key value pairs
The parameters used. Either a CultureHosts record ID or an array of arguments in key value pairs
|
#
|