Parse PHP SDK API Reference

ParseQuery
in package

Class ParseQuery - Handles querying data from Parse.

Tags
author

Fosco Marotto [email protected]

Table of Contents

$className  : string
Class name for data stored on Parse.
$count  : int
Determines if the query is a count query or a results query.
$excludes  : array<string|int, mixed>
Exclude keys.
$includeReadPreference  : string
The read preference for the queries to include pointers.
$includes  : array<string|int, mixed>
Include nested objects.
$limit  : int
Limit of results, defaults to 100 when not explicitly set.
$orderBy  : array<string|int, mixed>
Order By keys.
$readPreference  : string
The read preference for the main query.
$selectedKeys  : array<string|int, mixed>
Include certain keys only.
$skip  : int
Skip from the beginning of the search results.
$subqueryReadPreference  : string
The read preference for the sub queries.
$where  : array<string|int, mixed>
Where constraints.
__construct()  : mixed
Create a Parse Query for a given Parse Class.
_getOptions()  : array<string|int, mixed>
Returns an associative array of the query constraints.
_setConditions()  : mixed
Sets the conditions of this parse query from an array
addAscending()  : ParseQuery
Set the query orderBy to ascending for the given key(s). It can also add secondary sort descriptors without overwriting the existing order.
addDescending()  : ParseQuery
Set the query orderBy to descending for a given key(s). It can also add secondary sort descriptors without overwriting the existing order.
aggregate()  : array<string|int, mixed>
Execute an aggregate query and returns aggregate results.
andQueries()  : ParseQuery
Constructs a ParseQuery object that is the AND of the passed in queries objects.
ascending()  : ParseQuery
Set the query orderBy to ascending for the given key(s). It overwrites the existing order criteria.
containedBy()  : ParseQuery
Adds a constraint to the query that requires a particular key's value to be contained by the provided list of values. Get objects where all array elements match.
containedIn()  : ParseQuery
Add a constraint to the query that requires a particular key's value to be contained in the provided list of values.
contains()  : ParseQuery
Adds a constraint for finding string values that contain a provided string. This may be slow for large datasets.
containsAll()  : ParseQuery
Add a constraint to the query that requires a particular key's value to contain each one of the provided list of values.
containsAllStartingWith()  : ParseQuery
Add a constraint to the query that requires a particular key's value to contain each one of the provided list of values starting with the given string.
count()  : int
Execute a count query and return the count.
descending()  : ParseQuery
Set the query orderBy to descending for a given key(s). It overwrites the existing order criteria.
distinct()  : array<string|int, mixed>
Execute a distinct query and return unique values.
doesNotExist()  : ParseQuery
Add a constraint for finding objects that not contain the given key.
doesNotMatchKeyInQuery()  : ParseQuery
Add a constraint that requires that a key's value not match a value in an object returned by the given query.
doesNotMatchQuery()  : ParseQuery
Add a constraint that requires that a key's value not matches a ParseQuery constraint.
each()  : mixed
Iterates over each result of a query, calling a callback for each one. The items are processed in an unspecified order. The query may not have any sort order, and may not use limit or skip.
endsWith()  : ParseQuery
Add a constraint to the query that requires a particular key's value to end with the provided value.
equalTo()  : ParseQuery
Set a constraint for a field matching a given value.
excludeKey()  : ParseQuery
Restricts the fields of the returned Parse.Objects to all keys except the provided keys. Exclude takes precedence over select and include.
exists()  : ParseQuery
Add a constraint for finding objects that contain the given key.
find()  : array<string|int, ParseObject>
Execute a find query and return the results.
first()  : array<string|int, mixed>|ParseObject
Execute a query to get only the first result.
fullText()  : ParseQuery
Adds a constraint for finding string values that contain a provided string using Full Text Search
get()  : array<string|int, mixed>|ParseObject
Execute a query to retrieve a specific object.
greaterThan()  : ParseQuery
Add a constraint to the query that requires a particular key's value to be greater than the provided value.
greaterThanOrEqualTo()  : ParseQuery
Add a constraint to the query that requires a particular key's value to be greater than or equal to the provided value.
greaterThanOrEqualToRelativeTime()  : ParseQuery
Add a constraint to the query that requires a particular key's value to be greater than or equal to the provided relative time string.
greaterThanRelativeTime()  : ParseQuery
Add a constraint to the query that requires a particular key's value to be greater than the provided relative time string.
handleQueryResult()  : array<string|int, mixed>
Handles result from ParseClient::_request
includeAllKeys()  : ParseQuery
Includes all nested Parse.Objects.
includeKey()  : ParseQuery
Include nested Parse Objects for the provided key. You can use dot notation to specify which fields in the included object are also fetch.
lessThan()  : ParseQuery
Add a constraint to the query that requires a particular key's value to be less than the provided value.
lessThanOrEqualTo()  : ParseQuery
Add a constraint to the query that requires a particular key's value to be less than or equal to the provided value.
lessThanOrEqualToRelativeTime()  : ParseQuery
Add a constraint to the query that requires a particular key's value to be less than or equal to the provided date string.
lessThanRelativeTime()  : ParseQuery
Add a constraint to the query that requires a particular key's value to be less than the provided relative time string.
limit()  : ParseQuery
Set the limit parameter as a query constraint.
matches()  : ParseQuery
Adds a regular expression constraint for finding string values that match the provided regular expression.
matchesKeyInQuery()  : ParseQuery
Add a constraint that requires that a key's value matches a value in an object returned by the given query.
matchesQuery()  : ParseQuery
Add a constraint that requires that a key's value matches a ParseQuery constraint.
near()  : ParseQuery
Add a proximity based constraint for finding objects with key point values near the point given.
norQueries()  : ParseQuery
Constructs a ParseQuery object that is the NOR of the passed in queries objects.
notContainedIn()  : ParseQuery
Add a constraint to the query that requires a particular key's value to not be contained in the provided list of values.
notEqualTo()  : ParseQuery
Add a constraint to the query that requires a particular key's value to be not equal to the provided value.
orQueries()  : ParseQuery
Constructs a ParseQuery object that is the OR of the passed in queries objects.
polygonContains()  : ParseQuery
Add a constraint to the query that requires a particular key's coordinates that contains a ParseGeoPoint
readPreference()  : ParseQuery
Changes the read preference that the backend will use when performing the query to the database.
relatedTo()  : ParseQuery
Add constraint for parse relation.
select()  : ParseQuery
Restrict the fields of the returned Parse Objects to include only the provided keys. If this is called multiple times, then all of the keys specified in each of the calls will be included.
skip()  : ParseQuery
Set the skip parameter as a query constraint.
startsWith()  : ParseQuery
Add a constraint to the query that requires a particular key's value to start with the provided value.
withCount()  : ParseQuery
The response will include the total number of objects satisfying this query, dispite limit / skip. Might be useful for pagination.
withinGeoBox()  : ParseQuery
Add a constraint to the query that requires a particular key's coordinates be contained within a given rectangular geographic bounding box.
withinKilometers()  : ParseQuery
Add a proximity based constraint for finding objects with key point values near the point given and within the maximum distance given.
withinMiles()  : ParseQuery
Add a proximity based constraint for finding objects with key point values near the point given and within the maximum distance given.
withinPolygon()  : ParseQuery
Add a constraint to the query that requires a particular key's coordinates be contained within and on the bounds of a given polygon Supports closed and open (last point is connected to first) paths
withinRadians()  : ParseQuery
Add a proximity based constraint for finding objects with key point values near the point given and within the maximum distance given.
_and()  : ParseQuery
Add constraint that at all of the passed in queries matches.
_matchClassname()  : string
All queries must have same class name.
_mergeQueries()  : ParseQuery
Combines queries for NOR, AND, OR queries.
_nor()  : ParseQuery
Add constraint that at none of the passed in queries matches.
_or()  : ParseQuery
Add constraint that at least one of the passed in queries matches.
addCondition()  : mixed
Helper for condition queries.
buildQueryString()  : string
Build query string from query constraints.
quote()  : string
Converts a string into a regex that matches it.
regexStartWith()  : string
Converts a string into a regex that matches it at the beginning

Properties

$className

Class name for data stored on Parse.

private string $className

$count

Determines if the query is a count query or a results query.

private int $count

$excludes

Exclude keys.

private array<string|int, mixed> $excludes = []

$includeReadPreference

The read preference for the queries to include pointers.

private string $includeReadPreference

$includes

Include nested objects.

private array<string|int, mixed> $includes = []

$limit

Limit of results, defaults to 100 when not explicitly set.

private int $limit = -1

$orderBy

Order By keys.

private array<string|int, mixed> $orderBy = []

$readPreference

The read preference for the main query.

private string $readPreference

$selectedKeys

Include certain keys only.

private array<string|int, mixed> $selectedKeys = []

$skip

Skip from the beginning of the search results.

private int $skip = 0

$subqueryReadPreference

The read preference for the sub queries.

private string $subqueryReadPreference

$where

Where constraints.

private array<string|int, mixed> $where = []

Methods

__construct()

Create a Parse Query for a given Parse Class.

public __construct(mixed $className) : mixed
Parameters
$className : mixed

Class Name of data on Parse.

Return values
mixed

_getOptions()

Returns an associative array of the query constraints.

public _getOptions() : array<string|int, mixed>
Return values
array<string|int, mixed>

_setConditions()

Sets the conditions of this parse query from an array

public _setConditions(array<string|int, mixed> $conditions) : mixed
Parameters
$conditions : array<string|int, mixed>

Array of Conditions to set

Tags
throws
ParseException
Return values
mixed

addAscending()

Set the query orderBy to ascending for the given key(s). It can also add secondary sort descriptors without overwriting the existing order.

public addAscending(mixed $key) : ParseQuery
Parameters
$key : mixed

Key(s) to sort by, which is a string or an array of strings.

Return values
ParseQuery

Returns this query, so you can chain this call.

addDescending()

Set the query orderBy to descending for a given key(s). It can also add secondary sort descriptors without overwriting the existing order.

public addDescending(mixed $key) : ParseQuery
Parameters
$key : mixed

Key(s) to sort by, which is a string or an array of strings.

Return values
ParseQuery

Returns this query, so you can chain this call.

aggregate()

Execute an aggregate query and returns aggregate results.

public aggregate(array<string|int, mixed> $pipeline) : array<string|int, mixed>
Parameters
$pipeline : array<string|int, mixed>

stages to process query

Return values
array<string|int, mixed>

andQueries()

Constructs a ParseQuery object that is the AND of the passed in queries objects.

public static andQueries(array<string|int, mixed> $queryObjects) : ParseQuery

All queries must have same class name.

Parameters
$queryObjects : array<string|int, mixed>

Array of ParseQuery objects to AND.

Tags
throws
Exception

If all queries don't have same class.

Return values
ParseQuery

The query that is the AND of the passed in queries.

ascending()

Set the query orderBy to ascending for the given key(s). It overwrites the existing order criteria.

public ascending(mixed $key) : ParseQuery
Parameters
$key : mixed

Key(s) to sort by, which is a string or an array of strings.

Return values
ParseQuery

Returns this query, so you can chain this call.

containedBy()

Adds a constraint to the query that requires a particular key's value to be contained by the provided list of values. Get objects where all array elements match.

public containedBy(string $key, mixed $value) : ParseQuery
Parameters
$key : string

The key to check.

$value : mixed

The values that will match.

Return values
ParseQuery

Returns this query, so you can chain this call.

containedIn()

Add a constraint to the query that requires a particular key's value to be contained in the provided list of values.

public containedIn(string $key, array<string|int, mixed> $values) : ParseQuery
Parameters
$key : string

The key to check.

$values : array<string|int, mixed>

The values that will match.

Return values
ParseQuery

Returns the query, so you can chain this call.

contains()

Adds a constraint for finding string values that contain a provided string. This may be slow for large datasets.

public contains(string $key, mixed $value) : ParseQuery
Parameters
$key : string

The key to check.

$value : mixed

The substring that the value must contain.

Return values
ParseQuery

Returns this query, so you can chain this call.

containsAll()

Add a constraint to the query that requires a particular key's value to contain each one of the provided list of values.

public containsAll(string $key, array<string|int, mixed> $values) : ParseQuery
Parameters
$key : string

The key to check. This key's value must be an array.

$values : array<string|int, mixed>

The values that will match.

Return values
ParseQuery

Returns the query, so you can chain this call.

containsAllStartingWith()

Add a constraint to the query that requires a particular key's value to contain each one of the provided list of values starting with the given string.

public containsAllStartingWith(string $key, array<string|int, mixed> $values) : ParseQuery
Parameters
$key : string

The key to check. This key's value must be an array.

$values : array<string|int, mixed>

The values that will match as starting string.

Return values
ParseQuery

Returns the query, so you can chain this call.

count()

Execute a count query and return the count.

public count([bool $useMasterKey = false ]) : int
Parameters
$useMasterKey : bool = false

If the query should use the master key

Return values
int

descending()

Set the query orderBy to descending for a given key(s). It overwrites the existing order criteria.

public descending(mixed $key) : ParseQuery
Parameters
$key : mixed

Key(s) to sort by, which is a string or an array of strings.

Return values
ParseQuery

Returns this query, so you can chain this call.

distinct()

Execute a distinct query and return unique values.

public distinct(string $key) : array<string|int, mixed>
Parameters
$key : string

field to find distinct values

Return values
array<string|int, mixed>

doesNotExist()

Add a constraint for finding objects that not contain the given key.

public doesNotExist(string $key) : ParseQuery
Parameters
$key : string

The key that should not exist.

Return values
ParseQuery

Returns the query, so you can chain this call.

doesNotMatchKeyInQuery()

Add a constraint that requires that a key's value not match a value in an object returned by the given query.

public doesNotMatchKeyInQuery(string $key, string $queryKey, ParseQuery $query) : ParseQuery
Parameters
$key : string

The key that contains teh value that is being excluded.

$queryKey : string

The key in objects returned by the query to match against.

$query : ParseQuery

The query to run.

Return values
ParseQuery

Returns the query, so you can chain this call.

doesNotMatchQuery()

Add a constraint that requires that a key's value not matches a ParseQuery constraint.

public doesNotMatchQuery(string $key, ParseQuery $query) : ParseQuery
Parameters
$key : string

The key that the contains the object not to match the query.

$query : ParseQuery

The query that should not match.

Return values
ParseQuery

Returns the query, so you can chain this call.

each()

Iterates over each result of a query, calling a callback for each one. The items are processed in an unspecified order. The query may not have any sort order, and may not use limit or skip.

public each(callable $callback[, bool $useMasterKey = false ][, int $batchSize = 100 ]) : mixed
Parameters
$callback : callable

Callback that will be called with each result of the query.

$useMasterKey : bool = false
$batchSize : int = 100
Tags
throws
Exception

If query has sort, skip, or limit.

Return values
mixed

endsWith()

Add a constraint to the query that requires a particular key's value to end with the provided value.

public endsWith(string $key, mixed $value) : ParseQuery
Parameters
$key : string

The key to check.

$value : mixed

The substring that the value must end with.

Return values
ParseQuery

Returns this query, so you can chain this call.

equalTo()

Set a constraint for a field matching a given value.

public equalTo(string $key, mixed $value) : ParseQuery
Parameters
$key : string

Key to set up an equals constraint.

$value : mixed

Value the key must equal.

Return values
ParseQuery

Returns this query, so you can chain this call.

excludeKey()

Restricts the fields of the returned Parse.Objects to all keys except the provided keys. Exclude takes precedence over select and include.

public excludeKey(mixed $key) : ParseQuery

(Requires Parse Server 3.6.0+)

Parameters
$key : mixed

The name(s) of the key(s) to exclude. It could be string, or an Array of string.

Return values
ParseQuery

Returns the query, so you can chain this call.

exists()

Add a constraint for finding objects that contain the given key.

public exists(string $key) : ParseQuery
Parameters
$key : string

The key that should exist.

Return values
ParseQuery

Returns the query, so you can chain this call.

find()

Execute a find query and return the results.

public find([bool $useMasterKey = false ][, bool $decodeObjects = true ]) : array<string|int, ParseObject>
Parameters
$useMasterKey : bool = false
$decodeObjects : bool = true

If set to false, will return raw data instead of ParseObject instances

Return values
array<string|int, ParseObject>

first()

Execute a query to get only the first result.

public first([bool $useMasterKey = false ][, bool $decodeObjects = true ]) : array<string|int, mixed>|ParseObject
Parameters
$useMasterKey : bool = false

If the query should use the master key

$decodeObjects : bool = true

If set to false, will return raw data instead of ParseObject instances

Return values
array<string|int, mixed>|ParseObject

Returns the first object or an empty array

fullText()

Adds a constraint for finding string values that contain a provided string using Full Text Search

public fullText(string $key, mixed $value) : ParseQuery
Parameters
$key : string

The key to check.

$value : mixed

The substring that the value must contain.

Return values
ParseQuery

Returns this query, so you can chain this call.

get()

Execute a query to retrieve a specific object.

public get(string $objectId[, bool $useMasterKey = false ]) : array<string|int, mixed>|ParseObject
Parameters
$objectId : string

Unique object id to retrieve.

$useMasterKey : bool = false

If the query should use the master key

Tags
throws
ParseException
Return values
array<string|int, mixed>|ParseObject

Returns the selected object or an empty array

greaterThan()

Add a constraint to the query that requires a particular key's value to be greater than the provided value.

public greaterThan(string $key, mixed $value) : ParseQuery
Parameters
$key : string

The key to check.

$value : mixed

The value that provides an Lower bound.

Return values
ParseQuery

Returns this query, so you can chain this call.

greaterThanOrEqualTo()

Add a constraint to the query that requires a particular key's value to be greater than or equal to the provided value.

public greaterThanOrEqualTo(string $key, mixed $value) : ParseQuery
Parameters
$key : string

The key to check.

$value : mixed

The value that provides a lower bound.

Return values
ParseQuery

Returns this query, so you can chain this call.

greaterThanOrEqualToRelativeTime()

Add a constraint to the query that requires a particular key's value to be greater than or equal to the provided relative time string.

public greaterThanOrEqualToRelativeTime(string $key, string $relativeTime) : ParseQuery
Parameters
$key : string

The key to check.

$relativeTime : string

The relative time that provides a lower bound

Return values
ParseQuery

Returns this query, so you can chain this call.

greaterThanRelativeTime()

Add a constraint to the query that requires a particular key's value to be greater than the provided relative time string.

public greaterThanRelativeTime(string $key, string $relativeTime) : ParseQuery
Parameters
$key : string

The key to check

$relativeTime : string

The relative time that provides a lower bound

Return values
ParseQuery

Returns this query, so you can chain this call.

handleQueryResult()

Handles result from ParseClient::_request

public handleQueryResult(array<string|int, mixed> $result, bool $decodeObjects) : array<string|int, mixed>
Parameters
$result : array<string|int, mixed>

Array of ParseObject raw data.

$decodeObjects : bool

If set to false, will return raw data instead of ParseObject instances

Return values
array<string|int, mixed>

Array of ParseObjects or raw data.

includeAllKeys()

Includes all nested Parse.Objects.

public includeAllKeys() : ParseQuery

Requires Parse Server 3.0.0+

Return values
ParseQuery

Returns the query, so you can chain this call.

includeKey()

Include nested Parse Objects for the provided key. You can use dot notation to specify which fields in the included object are also fetch.

public includeKey(mixed $key) : ParseQuery

You can include all nested Parse Objects by passing in '*'. (Requires Parse Server 3.0.0+)

Parameters
$key : mixed

The name(s) of the key(s) to include. It could be string, or an Array of string.

Return values
ParseQuery

Returns the query, so you can chain this call.

lessThan()

Add a constraint to the query that requires a particular key's value to be less than the provided value.

public lessThan(string $key, mixed $value) : ParseQuery
Parameters
$key : string

The key to check.

$value : mixed

The value that provides an Upper bound.

Return values
ParseQuery

Returns this query, so you can chain this call.

lessThanOrEqualTo()

Add a constraint to the query that requires a particular key's value to be less than or equal to the provided value.

public lessThanOrEqualTo(string $key, mixed $value) : ParseQuery
Parameters
$key : string

The key to check.

$value : mixed

The value that provides an upper bound.

Return values
ParseQuery

Returns this query, so you can chain this call.

lessThanOrEqualToRelativeTime()

Add a constraint to the query that requires a particular key's value to be less than or equal to the provided date string.

public lessThanOrEqualToRelativeTime(string $key, string $relativeTime) : ParseQuery
Parameters
$key : string

The key to check.

$relativeTime : string

The relative time that provides an upper bound

Return values
ParseQuery

Returns this query, so you can chain this call.

lessThanRelativeTime()

Add a constraint to the query that requires a particular key's value to be less than the provided relative time string.

public lessThanRelativeTime(string $key, string $relativeTime) : ParseQuery
Parameters
$key : string

The key to check

$relativeTime : string

The relative time that provides an upper bound

Return values
ParseQuery

Returns this query, so you can chain this call.

limit()

Set the limit parameter as a query constraint.

public limit(int $n) : ParseQuery
Parameters
$n : int

Number of objects to return from the query.

Return values
ParseQuery

Returns this query, so you can chain this call.

matches()

Adds a regular expression constraint for finding string values that match the provided regular expression.

public matches(string $key, string $regex[, string $modifiers = '' ]) : ParseQuery

This may be slow for large datasets.

Parameters
$key : string

The key that the string to match is stored in.

$regex : string

The regular expression pattern to match.

$modifiers : string = ''

Modifies the search, supports i, m

Return values
ParseQuery

Returns the query, so you can chain this call.

matchesKeyInQuery()

Add a constraint that requires that a key's value matches a value in an object returned by the given query.

public matchesKeyInQuery(string $key, string $queryKey, ParseQuery $query) : ParseQuery
Parameters
$key : string

The key that contains the value that is being matched.

$queryKey : string

The key in objects returned by the query to match against.

$query : ParseQuery

The query to run.

Return values
ParseQuery

Returns the query, so you can chain this call.

matchesQuery()

Add a constraint that requires that a key's value matches a ParseQuery constraint.

public matchesQuery(string $key, ParseQuery $query) : ParseQuery
Parameters
$key : string

The key that the contains the object to match the query.

$query : ParseQuery

The query that should match.

Return values
ParseQuery

Returns the query, so you can chain this call.

near()

Add a proximity based constraint for finding objects with key point values near the point given.

public near(string $key, ParseGeoPoint $point) : ParseQuery
Parameters
$key : string

The key that the ParseGeoPoint is stored in.

$point : ParseGeoPoint

The reference ParseGeoPoint that is used.

Return values
ParseQuery

Returns this query, so you can chain this call.

norQueries()

Constructs a ParseQuery object that is the NOR of the passed in queries objects.

public static norQueries(array<string|int, mixed> $queryObjects) : ParseQuery

All queries must have same class name.

Parameters
$queryObjects : array<string|int, mixed>

Array of ParseQuery objects to NOR.

Tags
throws
Exception

If all queries don't have same class.

Return values
ParseQuery

The query that is the NOR of the passed in queries.

notContainedIn()

Add a constraint to the query that requires a particular key's value to not be contained in the provided list of values.

public notContainedIn(string $key, array<string|int, mixed> $values) : ParseQuery
Parameters
$key : string

The key to check.

$values : array<string|int, mixed>

The values that will not match.

Return values
ParseQuery

Returns the query, so you can chain this call.

notEqualTo()

Add a constraint to the query that requires a particular key's value to be not equal to the provided value.

public notEqualTo(string $key, mixed $value) : ParseQuery
Parameters
$key : string

The key to check.

$value : mixed

The value that must not be equalled.

Return values
ParseQuery

Returns this query, so you can chain this call.

orQueries()

Constructs a ParseQuery object that is the OR of the passed in queries objects.

public static orQueries(array<string|int, mixed> $queryObjects) : ParseQuery

All queries must have same class name.

Parameters
$queryObjects : array<string|int, mixed>

Array of ParseQuery objects to OR.

Tags
throws
Exception

If all queries don't have same class.

Return values
ParseQuery

The query that is the OR of the passed in queries.

polygonContains()

Add a constraint to the query that requires a particular key's coordinates that contains a ParseGeoPoint

public polygonContains(string $key, ParseGeoPoint $point) : ParseQuery
Parameters
$key : string

The key of the ParsePolygon

$point : ParseGeoPoint

The point that will be contained.

Return values
ParseQuery

Returns this query, so you can chain this call.

readPreference()

Changes the read preference that the backend will use when performing the query to the database.

public readPreference(string $readPreference[, string $includeReadPreference = null ][, string $subqueryReadPreference = null ]) : ParseQuery
Parameters
$readPreference : string

The read preference for the main query.

$includeReadPreference : string = null

The read preference for the queries to include pointers.

$subqueryReadPreference : string = null

The read preference for the sub queries.

Return values
ParseQuery

Returns the query, so you can chain this call.

relatedTo()

Add constraint for parse relation.

public relatedTo(string $key, mixed $value) : ParseQuery
Parameters
$key : string
$value : mixed
Return values
ParseQuery

Returns the query, so you can chain this call.

select()

Restrict the fields of the returned Parse Objects to include only the provided keys. If this is called multiple times, then all of the keys specified in each of the calls will be included.

public select(mixed $key) : ParseQuery
Parameters
$key : mixed

The name(s) of the key(s) to include. It could be string, or an Array of string.

Return values
ParseQuery

Returns the query, so you can chain this call.

skip()

Set the skip parameter as a query constraint.

public skip(int $n) : ParseQuery
Parameters
$n : int

Number of objects to skip from start of results.

Return values
ParseQuery

Returns this query, so you can chain this call.

startsWith()

Add a constraint to the query that requires a particular key's value to start with the provided value.

public startsWith(string $key, mixed $value) : ParseQuery
Parameters
$key : string

The key to check.

$value : mixed

The substring that the value must start with.

Return values
ParseQuery

Returns this query, so you can chain this call.

withCount()

The response will include the total number of objects satisfying this query, dispite limit / skip. Might be useful for pagination.

public withCount([bool $includeCount = true ]) : ParseQuery

Note: the results will be an object results: holding {ParseObject} array and count: integer holding total number

Parameters
$includeCount : bool = true

If response should include count, true by default.

Return values
ParseQuery

Returns this query, so you can chain this call.

withinGeoBox()

Add a constraint to the query that requires a particular key's coordinates be contained within a given rectangular geographic bounding box.

public withinGeoBox(string $key, ParseGeoPoint $southwest, ParseGeoPoint $northeast) : ParseQuery
Parameters
$key : string

The key of the ParseGeoPoint

$southwest : ParseGeoPoint

The lower-left corner of the box.

$northeast : ParseGeoPoint

The upper-right corner of the box.

Return values
ParseQuery

Returns this query, so you can chain this call.

withinKilometers()

Add a proximity based constraint for finding objects with key point values near the point given and within the maximum distance given.

public withinKilometers(string $key, ParseGeoPoint $point, int $maxDistance[, bool $sort = true ]) : ParseQuery

Radius of earth used is 6371.0 kilometers.

Parameters
$key : string

The key of the ParseGeoPoint

$point : ParseGeoPoint

The ParseGeoPoint that is used.

$maxDistance : int

Maximum distance (in kilometers)

$sort : bool = true

Return objects sorted by distance

Return values
ParseQuery

Returns this query, so you can chain this call.

withinMiles()

Add a proximity based constraint for finding objects with key point values near the point given and within the maximum distance given.

public withinMiles(string $key, ParseGeoPoint $point, int $maxDistance[, bool $sort = true ]) : ParseQuery

Radius of earth used is 3958.8 miles.

Parameters
$key : string

The key of the ParseGeoPoint

$point : ParseGeoPoint

The ParseGeoPoint that is used.

$maxDistance : int

Maximum distance (in miles)

$sort : bool = true

Return objects sorted by distance

Return values
ParseQuery

Returns this query, so you can chain this call.

withinPolygon()

Add a constraint to the query that requires a particular key's coordinates be contained within and on the bounds of a given polygon Supports closed and open (last point is connected to first) paths

public withinPolygon(string $key, array<string|int, mixed> $points) : ParseQuery

Polygon must have at least 3 points

Parameters
$key : string

The key of the ParseGeoPoint

$points : array<string|int, mixed>

Array of ParseGeoPoint

Return values
ParseQuery

Returns this query, so you can chain this call.

withinRadians()

Add a proximity based constraint for finding objects with key point values near the point given and within the maximum distance given.

public withinRadians(string $key, ParseGeoPoint $point, int $maxDistance[, bool $sort = true ]) : ParseQuery
Parameters
$key : string

The key of the ParseGeoPoint

$point : ParseGeoPoint

The ParseGeoPoint that is used.

$maxDistance : int

Maximum distance (in radians)

$sort : bool = true

Return objects sorted by distance

Return values
ParseQuery

Returns this query, so you can chain this call.

_and()

Add constraint that at all of the passed in queries matches.

private _and(array<string|int, mixed> $queries) : ParseQuery
Parameters
$queries : array<string|int, mixed>

The list of queries to OR.

Return values
ParseQuery

Returns the query, so you can chain this call.

_matchClassname()

All queries must have same class name.

private static _matchClassname(array<string|int, mixed> $queryObjects) : string
Parameters
$queryObjects : array<string|int, mixed>

Array of ParseQuery objects.

Tags
throws
Exception

If all queries don't have same class.

Return values
string

class name.

_mergeQueries()

Combines queries for NOR, AND, OR queries.

private _mergeQueries(string $key, array<string|int, mixed> $queries) : ParseQuery
Parameters
$key : string

The condition $and, $or, $nor.

$queries : array<string|int, mixed>

The list of queries to combine.

Return values
ParseQuery

Returns the query, so you can chain this call.

_nor()

Add constraint that at none of the passed in queries matches.

private _nor(array<string|int, mixed> $queries) : ParseQuery
Parameters
$queries : array<string|int, mixed>

The list of queries to NOR.

Return values
ParseQuery

Returns the query, so you can chain this call.

_or()

Add constraint that at least one of the passed in queries matches.

private _or(array<string|int, mixed> $queries) : ParseQuery
Parameters
$queries : array<string|int, mixed>

The list of queries to OR.

Return values
ParseQuery

Returns the query, so you can chain this call.

addCondition()

Helper for condition queries.

private addCondition(string $key, string $condition, mixed $value) : mixed
Parameters
$key : string

The key to where constraints

$condition : string

The condition name

$value : mixed

The condition value, can be a string or an array of strings

Tags
throws
Exception
Return values
mixed

buildQueryString()

Build query string from query constraints.

private buildQueryString(array<string|int, mixed> $queryOptions) : string
Parameters
$queryOptions : array<string|int, mixed>

Associative array of the query constraints.

Return values
string

Query string.

quote()

Converts a string into a regex that matches it.

private quote(mixed $s) : string

Surrounding with \Q .. \E does this, we just need to escape \E's in the text separately.

Parameters
$s : mixed

The string or array being replaced.

Return values
string

Returns the string converted.

regexStartWith()

Converts a string into a regex that matches it at the beginning

private regexStartWith(mixed $s) : string
Parameters
$s : mixed

The string or array being replaced.

Return values
string

Returns the string converted.

Search results