mysql_xdevapi\Collection
PHP Manual

Collection::remove

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

Collection::removeRemove collection documents

说明

public mysql_xdevapi\CollectionRemove mysql_xdevapi\Collection::remove ( string $search_condition )

Remove collections that meet specific search conditions. Multiple operations are allowed, and parameter binding is supported.

参数

search_condition

Must be a valid SQL expression used to match the documents to modify. This expression might be as simple as TRUE, which matches all documents, or it might use functions and operators such as 'CAST(_id AS SIGNED) >= 10', 'age MOD 2 = 0 OR age MOD 3 = 0', or '_id IN ["2","5","7","10"]'.

返回值

If the operation is not executed, then the function will return a Remove object that can be used to add additional remove operations.

If the remove operation is executed, then the returned object will contain the result of the operation.

范例

Example #1 mysql_xdevapi\Collection::remove() example

<?php
// Assuming $coll is a valid Collection object

// Remove all the documents for which the 'age' field is between 20 and 50
$coll->remove('age > :age_from and age < :age_to')->bind(['age_from' => 20'age_to' => 50])->limit(7)->execute();

// Select for removal all the documents, sort them by age (descending) and remove only the first 2
$coll->remove('true')->sort('age desc')->limit(2)->execute();
?>

mysql_xdevapi\Collection
PHP Manual