mysql_xdevapi\CollectionModify
PHP Manual

CollectionModify::arrayDelete

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

CollectionModify::arrayDeleteDelete element

说明

public mysql_xdevapi\CollectionModify mysql_xdevapi\CollectionModify::arrayDelete ( string $collection_field )

Delete a document field element. If the deleted element is the only element then the field is removed.

参数

collection_field

The format of this parameter is FIELD_NAME[ INDEX ] where FIELD_NAME is the name of the document field to remove the element from, and INDEX is the INDEX of the element within the field.

The INDEX field is zero based, so the leftmost item from the array has an index of 0.

返回值

A CollectionModify object that can be used to execute the command, or to add further operations

范例

Example #1 mysql_xdevapi\CollectionModify::arrayDelete() example

<?php

// Assuming $coll is a valid Collection object

// Remove the first element from the array of 'jobs' for all the documents
// with name like Riccardo or Carlo
$coll->modify("name in ('Riccardo', 'Carlo')")->arrayDelete('job[0]')->execute();

// Remove the second element from the documents which `age` field is greater than 30
$coll->modify('age > 30')->arrayDelete('job[1]')->execute();

?>

mysql_xdevapi\CollectionModify
PHP Manual