Home  >  Article  >  Backend Development  >  Parsing common mongodb query operations in PHP_PHP tutorial

Parsing common mongodb query operations in PHP_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:05:04876browse

Copy code The code is as follows:

// The field string is
$querys = array ("name"=>"shian");

// What is the value equal to?
$querys = array("number"=>7);

// What is the value greater than How many
$querys = array("number"=>array('$gt' => 5));

// How many values ​​are greater than or equal to
$querys = array("number "=>array('$gte' => 2));

//How much the value is less than?
$querys = array("number"=>array('$lt' => ; 5));

//How many values ​​are less than or equal to
$querys = array("number"=>array('$lte' => 2));

// What is the value between
$querys = array("number"=>array('$gt' => 1,'$lt' => 9));

// The value is not equal to a certain value
$querys = array("number"=>array('$ne' => 9));

// Use js to query the conditions
$js = "function(){
return this.number == 2 && this.name == 'shian';
}";
$querys = array('$where'=>$js) ;

//What values ​​does the field equal?
$querys = array("number"=>array('$in' => array(1,2,9)));

//What values ​​does the field not equal?
$querys = array("number"=>array('$nin' => array(1,2,9)));

// Use regular query
$querys = array("name" => new MongoRegex("/shi/$i"));

// or
$querys = array ('$or' => array(array('number'=>2),array('number'=>9)));
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327720.htmlTechArticleCopy the code as follows: ?php // The field string is $querys = array("name"=" shian"); // What is the value equal to? $querys = array("number"=7); // What is the value greater than? $querys = array("number...
Statement:
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