mysql_xdevapi\CollectionModify
PHP Manual

CollectionModify::arrayAppend

(No version information available, might only be in Git)

CollectionModify::arrayAppendAppend element to an array field

说明

public mysql_xdevapi\CollectionModify mysql_xdevapi\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.

参数

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();

?>

mysql_xdevapi\CollectionModify
PHP Manual