Php 而是加入SQL,MongoDB应该使用什么
我在Php 而是加入SQL,MongoDB应该使用什么,php,mongodb,Php,Mongodb,我在MongoDB数据库中有两个集合,我想加入PHP中的两个集合 我已经搜索过了,但不幸的是,我没有找到令人信服的答案。 数据如下所示: users { "_id": "4ca30369fd0e910ecc000006", "login": "user11", "pass": "example_pass", "date": "2017-12-15" } news "_id": "4ca305c2fd0e910ecc000003", "name": "news 333", "content":
MongoDB
数据库中有两个集合,我想加入PHP中的两个集合我已经搜索过了,但不幸的是,我没有找到令人信服的答案。
数据如下所示:
users
{
"_id": "4ca30369fd0e910ecc000006",
"login": "user11",
"pass": "example_pass",
"date": "2017-12-15"
}
news
"_id": "4ca305c2fd0e910ecc000003",
"name": "news 333",
"content": "news content",
"user_id": "4ca30373fd0e910ecc000007",
"date": "2017-12-15"
}
已经回答了
注意:我是一个吝啬的开发者
也就是说,我们使用.populate()
方法(mongoose)实现一个级别的连接
至于php
您可以使用不同于RDBMS的方法
数据复制
"news": {
"_id": "4ca305c2fd0e910ecc000003",
"name": "news one",
"content": "news one",
"user": {
"_id": "4ca30369fd0e910ecc000006",
"login": "user11"
},
"date": "2017-12-15"
}