Similar to the normal relational database, when the data is deleted, changed, check, you will use the query conditions, such as the Where in MySQL ...
In MongoDB, all the instructions that have been made by PHP are wrapped in arrays:
Mongocollection::update ( array $criteria , array $newobj [, array $options = Array ()])
Public Mongocursor Mongocollection::find ([ Array $query = array () [, Array $fields = Array ()]])
Public array Mongocollection::findone ([ Array $query = array () [, Array $fields = Array ()]])
Public mixed Mongocollection::remove ( array $criteria [, Array $options = Array ()])
Of the above four items, the bold part is actually for us to fill in the location of the query conditions.
A simple example:
$query = Array (' a ' = = ' Hello ');
$coll->find ($query);
Queries all records in the collection that are equal to hello.
can also be compounded to do:
$query = Array (' a ' = = ' Hello ', ' B ' =>1);
$coll->find ($query);
Queries all records in the collection that are equal to Hello and B is 1.
For query conditions such as greater than and less than:
$query = Array (' a ' = = ' Hello ', ' B ' =>array (' $gt ' =>10));
$coll->find ($query);
Query for all records in the collection that are equal to Hello and B are greater than ten .
More size ratios: $GT is greater than, $GTE is greater than or equal, $lt is less than, $lte is less than or equal, $ne is not equal
"MongoDB tutorial 19th" PHP and MongoDB conditional query