use*_*659 5 php mysql select mongodb
如何在mongo db中编写查找查询以选择某些值.例如
IN MYSQL - SELECT * from things where id=3;
IN Mongo - thingscollection->find(array("_id" => $id))
Run Code Online (Sandbox Code Playgroud)
假设MYSQL查询看起来像这样,
SELECT name,age from things where id=3;
Run Code Online (Sandbox Code Playgroud)
我想知道如何在PHP/MongoDB中编写查找查询以选择特定值?
Yog*_*har 12
MySQL: SELECT name,age from things where id=3;
Mongo: $db->things->find(array("id" => 3), array("name" => 1, "age" => 1));
Run Code Online (Sandbox Code Playgroud)
您可能希望使用mongo _id
而不是自己创建的id
字段.
有关php驱动程序的更多信息:http://php.net/manual/en/mongo.sqltomongo.php 只有SQL到Mongo的另一个很好的链接是http://rickosborne.org/download/SQL-to- MongoDB.pdf
归档时间: |
|
查看次数: |
12584 次 |
最近记录: |