(No version information available, might only be in Git)
CollectionModify::arrayAppend — Append element to an array field
$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.
collection_field
The identifier of the field where the new element is inserted.
expression_or_literal
The new element to insert at the end of the document field array.
A CollectionModify object that can be used to execute the command, or to add additional operations.
Example #1 mysql_xdevapi\CollectionModify::arrayAppend() example
<?php
// Assuming $coll is a valid Collection object
// For each document with a `job` like Programmatore or Cantante, add an additional
// job: 'Volontario'
$coll->modify("job in ('Programmatore', 'Cantante')")->arrayAppend('job', 'Volontario')->execute();
?>