(No version information available, might only be in Git)
Collection::remove — Remove collection documents
$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();
?>