Parsing common MongoDB query operations in PHP _php tips

Source: Internet
Author: User
Tags mongodb mongodb query
Copy Code code as follows:

<?php
Field Word string
$querys = Array ("name" => "Shian");

The number is equal to how many
$querys = Array ("number" =>7);

How much is the value?
$querys = Array ("Number" =>array (' $gt ' => 5));

The number is greater than the amount of
$querys = Array ("Number" =>array (' $gte ' => 2));

The value is less than how much
$querys = Array ("Number" =>array (' $lt ' => 5));

The number is less than what is equal.
$querys = Array ("Number" =>array (' $lte ' => 2));

What is the number of numbers?
$querys = Array ("Number" =>array (' $gt ' => 1, ' $lt ' => 9));

Numbers are not equal to a value
$querys = Array ("Number" =>array (' $ne ' => 9));

Use JS to check the conditions
$js = "function () {
return This.number = = 2 && this.name = = ' Shian ';
}";
$querys = Array (' $where ' => $js);

What values are in the fields
$querys = Array ("Number" =>array (' $in ' => Array (1,2,9));

The margin is not equal to which values
$querys = Array ("Number" =>array (' $nin ' => Array (1,2,9));

Using the regular search
$querys = Array ("name" => new Mongoregex ("/shi/$i"));

Or
$querys = Array (' $or ' => Array (' number ' =>2), Array (' number ' =>9));
?>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.