class CollectionModify implements Executable, CrudOperationBindable, CrudOperationLimitable, CrudOperationSkippable, CrudOperationSortable (View source)

Class CollectionModify

Methods

arrayAppend(string $collection_field, string $expression_or_literal)

Add an element to a document's field, as multiple elements of a field are represented as an array. Unlike arrayInsert(), arrayAppend() always appends the new element at the end of the array, whereas arrayInsert() can define the location.

arrayInsert(string $collection_field, string $expression_or_literal)

Add an element to a document's field, as multiple elements of a field are represented as an array. Unlike arrayAppend(), arrayInsert() allows you to specify where the new element is inserted by defining which item it is after, whereas arrayAppend() always appends the new element at the end of the array.

bind(array $placeholder_values)

Bind a parameter to the placeholder in the search condition of the modify operation.

execute()

The execute method is required to send the CRUD operation request to the MySQL server.

limit(int $rows)

Limit the number of documents modified by this operation. Optionally combine with skip() to define an offset value.

patch(string $document)

Takes a patch object and applies it on one or more documents, and can update multiple document properties.

replace(string $collection_field, string $expression_or_literal)

Replace (update) a given field value with a new one.

set(string $collection_field, string $expression_or_literal)

Sets or updates attributes on documents in a collection.

skip(int $position)

Skip the first N elements that would otherwise be returned by a find operation. If the number of elements skipped is larger than the size of the result set, then the find operation returns an empty set.

sort(string $sort_expr)

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.

unset(array $fields)

Removes attributes from documents in a collection.

Details

CollectionModify arrayAppend(string $collection_field, string $expression_or_literal)

Add an element to a document's field, as multiple elements of a field are represented as an array. Unlike arrayInsert(), arrayAppend() always appends the new element at the end of the array, whereas arrayInsert() can define the location.

Parameters

string $collection_field
string $expression_or_literal

Return Value

CollectionModify

CollectionModify arrayInsert(string $collection_field, string $expression_or_literal)

Add an element to a document's field, as multiple elements of a field are represented as an array. Unlike arrayAppend(), arrayInsert() allows you to specify where the new element is inserted by defining which item it is after, whereas arrayAppend() always appends the new element at the end of the array.

Parameters

string $collection_field
string $expression_or_literal

Return Value

CollectionModify

CrudOperationBindable bind(array $placeholder_values)

Bind a parameter to the placeholder in the search condition of the modify operation.

The placeholder has the form of :NAME where ':' is a common prefix that must always exists before any NAME where NAME is the name of the placeholder. The bind method accepts a list of placeholders if multiple entities have to be substituted in the search condition of the modify operation.

Parameters

array $placeholder_values

Return Value

CrudOperationBindable

Result execute()

The execute method is required to send the CRUD operation request to the MySQL server.

Return Value

Result

CrudOperationLimitable limit(int $rows)

Limit the number of documents modified by this operation. Optionally combine with skip() to define an offset value.

Parameters

int $rows

Return Value

CrudOperationLimitable

CollectionModify patch(string $document)

Takes a patch object and applies it on one or more documents, and can update multiple document properties.

Parameters

string $document

Return Value

CollectionModify

CollectionModify replace(string $collection_field, string $expression_or_literal)

Replace (update) a given field value with a new one.

Parameters

string $collection_field
string $expression_or_literal

Return Value

CollectionModify

CollectionModify set(string $collection_field, string $expression_or_literal)

Sets or updates attributes on documents in a collection.

Parameters

string $collection_field
string $expression_or_literal

Return Value

CollectionModify

CrudOperationSkippable skip(int $position)

Skip the first N elements that would otherwise be returned by a find operation. If the number of elements skipped is larger than the size of the result set, then the find operation returns an empty set.

Parameters

int $position

Return Value

CrudOperationSkippable

CrudOperationSortable sort(string $sort_expr)

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

CollectionModify unset(array $fields)

Removes attributes from documents in a collection.

Parameters

array $fields

Return Value

CollectionModify