dougou8573 2018-08-02 06:43
浏览 74

如何直接从PHP运行Mongo Shell Query?

I want to run MongoDB raw query directly from PHP.

My query is like below.

var document_id = db.Document.aggregate([{$project: {"creationDate":1,'_id':1}},{$match: {"_id":ObjectID("5aa7a8852f4b3e2e86004837")}}]).toArray();

document_id = document_id[0]['_id'];

var upload_id = db.Upload.aggregate([{$project: {"creationDate":1,'_id':1}},{$match: {"_id":ObjectID("5aa7a8852f4b3e2e86004837")}}]).toArray();

upload_id = upload_id[0]['_id'];

and get result of those two variable document_id & upload_id of concat or multiple or addition.

( FYI: In real, I won't concat or multiply ids it is just for example. )

I have checked "http://php.net/manual/en/book.mongodb.php" for reference but nothing found useful.

Can anyone guide me on that ?

Version of MongoDB & PHP MongoDB driver I am using.

MongoDB version 3.6

MongoDB PHP Driver version 1.5

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
    • ¥15 cmd cl 0x000007b
    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
    • ¥500 火焰左右视图、视差(基于双目相机)
    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号