CollectionModify
class CollectionModify implements Executable, CrudOperationBindable, CrudOperationLimitable, CrudOperationSkippable, CrudOperationSortable (View source)
Class CollectionModify
Methods
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.
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 a parameter to the placeholder in the search condition of the modify operation.
The execute method is required to send the CRUD operation request to the MySQL server.
Limit the number of documents modified by this operation. Optionally combine with skip() to define an offset value.
Takes a patch object and applies it on one or more documents, and can update multiple document properties.
Replace (update) a given field value with a new one.
Sets or updates attributes on documents in a collection.
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 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.
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.
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.
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.
Result
execute()
The execute method is required to send the CRUD operation request to the MySQL server.
CrudOperationLimitable
limit(int $rows)
Limit the number of documents modified by this operation. Optionally combine with skip() to define an offset value.
CollectionModify
patch(string $document)
Takes a patch object and applies it on one or more documents, and can update multiple document properties.
CollectionModify
replace(string $collection_field, string $expression_or_literal)
Replace (update) a given field value with a new one.
CollectionModify
set(string $collection_field, string $expression_or_literal)
Sets or updates attributes on documents in a collection.
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.
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.
CollectionModify
unset(array $fields)
Removes attributes from documents in a collection.