note 113632 added to mongocollection.find
| From: | NanheKumar | Date: | Thu, 07 Nov 2013 21:13:31 +0000 |
| Subject: | note 113632 added to mongocollection.find | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-197458@lists.php.net to get a copy of this message | ||
<?php
$m = new MongoClient();
$db = $m->selectDB('school');
$collection = new MongoCollection($db, 'student');
//Find where class=5
$where=array('class'=>5);
$cursor = $collection->find($where);
//Find where class !=5
$where=array('class' => array('$ne'=>5));
$cursor = $collection->find($where);
//Find where age >20
$where=array('age' => array('$gt'=>20));
$cursor = $collection->find($where);
//Find where age >=20
$where=array('age' => array('$gte'=>20));
$cursor = $collection->find($where);
//Find where age <20
$where=array('age' => array('$le'=>20));
$cursor = $collection->find($where);
//Find where age <=20
$where=array('age' => array('$lte'=>20));
$cursor = $collection->find($where);
//Finc where class=10 or marks=80
$where=array( '$or' => array( array(' class' =>10),
array('marks'=>80) ) );
$cursor = $collection->find($where);
//Finc where class=12 AND marks=70
$where=array( '$and' => array( array(' class' =>12),
array('marks'=>70) ) );
$cursor = $collection->find($where);
?>
----
Server IP: 72.52.91.14
Probable Submitter: 72.52.91.14
----
Manual Page -- http://php.net/manual/en/mongocollection.find.php
Edit -- https://master.php.net/note/edit/113632
Del: integrated -- https://master.php.net/note/delete/113632/integrated
Del: useless -- https://master.php.net/note/delete/113632/useless
Del: bad code -- https://master.php.net/note/delete/113632/bad+code
Del: spam -- https://master.php.net/note/delete/113632/spam
Del: non-english -- https://master.php.net/note/delete/113632/non-english
Del: in docs -- https://master.php.net/note/delete/113632/in+docs
Del: other reasons-- https://master.php.net/note/delete/113632
Reject -- https://master.php.net/note/reject/113632
Search -- https://master.php.net/manage/user-notes.php