class CollectionFind implements Executable, CrudOperationBindable, CrudOperationLimitable, CrudOperationSortable (View source)

Class CollectionFind

Methods

bind(array $placeholder_values)

Bind value to query placeholder It allows the user to bind a parameter to the placeholder in the search condition of the find operation. The placeholder has the form of :NAME where ':' is a common prefix that must always exists before any NAME, NAME is the actual name of the placeholder. The bind function accepts a list of placeholders if multiple entities have to be substituted in the search condition.

execute()

Execute the find operation; this functionality allows for method chaining.

fields(string $projection)

Defined the columns for the query to return. If not defined then all columns are used.

groupBy(string $sort_expr)

This function can be used to group the result-set by one more columns, frequently this is used with aggregate functions like COUNT,MAX,MIN,SUM etc.

having(string $sort_expr)

This function can be used after the 'field' operation in order to make a selection on the documents to extract.

limit(int $rows)

Set the maximum number of documents to return.

lockExclusive(int $lock_waiting_option)

Execute operation with EXCLUSIVE LOCK

lockShared(int $lock_waiting_option)

Execute operation with SHARED LOCK

offset(int $position)

Skip given number of elements to be returned

sort(string $sort_expr)

Set the sorting criteria

Details

CrudOperationBindable bind(array $placeholder_values)

Bind value to query placeholder It allows the user to bind a parameter to the placeholder in the search condition of the find operation. The placeholder has the form of :NAME where ':' is a common prefix that must always exists before any NAME, NAME is the actual name of the placeholder. The bind function accepts a list of placeholders if multiple entities have to be substituted in the search condition.

Parameters

array $placeholder_values

Return Value

CrudOperationBindable

Result execute()

Execute the find operation; this functionality allows for method chaining.

Return Value

Result

CollectionFind fields(string $projection)

Defined the columns for the query to return. If not defined then all columns are used.

Parameters

string $projection

Return Value

CollectionFind

CollectionFind groupBy(string $sort_expr)

This function can be used to group the result-set by one more columns, frequently this is used with aggregate functions like COUNT,MAX,MIN,SUM etc.

Parameters

string $sort_expr

Return Value

CollectionFind

CollectionFind having(string $sort_expr)

This function can be used after the 'field' operation in order to make a selection on the documents to extract.

Parameters

string $sort_expr

Return Value

CollectionFind

CrudOperationLimitable limit(int $rows)

Set the maximum number of documents to return.

Parameters

int $rows

Return Value

CrudOperationLimitable

CollectionFind lockExclusive(int $lock_waiting_option)

Execute operation with EXCLUSIVE LOCK

Lock exclusively the document, other transactions are blocked from updating the document until the document is locked While the document is locked, other transactions are blocked from updating those docs, from doing SELECT ... LOCK IN SHARE MODE, or from reading the data in certain transaction isolation levels. Consistent reads ignore any locks set on the records that exist in the read view. This feature is directly useful with the modify() command, to avoid concurrency problems. Basically, it serializes access to a row through row locking

Parameters

int $lock_waiting_option

Return Value

CollectionFind

CollectionFind lockShared(int $lock_waiting_option)

Execute operation with SHARED LOCK

Allows to share the documents between multiple transactions which are locking in shared mode. Other sessions can read the rows, but cannot modify them until your transaction commits. If any of these rows were changed by another transaction that has not yet committed, your query waits until that transaction ends and then uses the latest values.

Parameters

int $lock_waiting_option

Return Value

CollectionFind

CollectionFind offset(int $position)

Skip given number of elements to be returned

Skip (offset) these number of elements that otherwise would be returned by the find operation. Use with the limit() method. Defining an offset larger than the result set size results in an empty set.

Parameters

int $position

Return Value

CollectionFind

CrudOperationSortable sort(string $sort_expr)

Set the sorting criteria

Sort the result set by the field selected in the sort_expr argument. The allowed orders are ASC (Ascending) or DESC (Descending). This operation is equivalent to the 'ORDER BY' SQL operation and it follows the same set of rules.

Parameters

string $sort_expr

Return Value

CrudOperationSortable