Home > Backend Development > PHP Tutorial > How to execute mongodb's $in and $size queries in PHP

How to execute mongodb's $in and $size queries in PHP

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-10-17 09:30:22
Original
1634 people have browsed it

Suppose there is such a set

<code>{ "_id" : ObjectId("5022518d09248743250688e0"), "name" : "big fruit", "fruits" : [ "apple", "pear", "orange" ] } , 
{ "_id" : ObjectId("502251a309248743250688e1"), "name" : "good fruit", "fruits" : [ "banana", "pear", "orange" ] }  ,
{ "_id" : ObjectId("502251c109248743250688e2"), "name" : "good fruit", "fruits" : [ "banana", "apple", "tomato" ] }  </code>
Copy after login
Copy after login

Suppose there is such a set

RT How to write two sentences of code in PHP

<code>db.coll.find({_id:{$in[ ObjectId("502251a309248743250688e1"), ObjectId("502251c109248743250688e2")]}})</code>
Copy after login
Copy after login

Query an array of length three

<code>db.coll.find({fruits:{$size:0}})</code>
Copy after login
Copy after login

How to implement it using PHP

Reply content:

Suppose there is such a set

<code>{ "_id" : ObjectId("5022518d09248743250688e0"), "name" : "big fruit", "fruits" : [ "apple", "pear", "orange" ] } , 
{ "_id" : ObjectId("502251a309248743250688e1"), "name" : "good fruit", "fruits" : [ "banana", "pear", "orange" ] }  ,
{ "_id" : ObjectId("502251c109248743250688e2"), "name" : "good fruit", "fruits" : [ "banana", "apple", "tomato" ] }  </code>
Copy after login
Copy after login

Suppose there is such a set

RT How to write two sentences of code in PHP

<code>db.coll.find({_id:{$in[ ObjectId("502251a309248743250688e1"), ObjectId("502251c109248743250688e2")]}})</code>
Copy after login
Copy after login

Query an array of length three

<code>db.coll.find({fruits:{$size:0}})</code>
Copy after login
Copy after login

How to implement it using PHP

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
mongodb start
From 1970-01-01 08:00:00
0
0
0
linux - ubuntu14 error installing mongodb
From 1970-01-01 08:00:00
0
0
0
Use of symfony2 mongodb
From 1970-01-01 08:00:00
0
0
0
mongodb _id rename
From 1970-01-01 08:00:00
0
0
0
Parameter understanding of mongodb
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template