我正在使用PHP查询MongoDB数据库,结果是文档响应作为嵌套数组的数组返回。
这是响应的var_dump:
Array
(
[_id] => MongoId Object
(
[$id] => 4ea06851fe90d0662900000a
)
[name] => Jason A,
[address] => Array
(
[0] => Array
(
[line1] => 123 Main St
[city] => Chicago
[zip] => 60611
[longitude] => -81.59
[county] => Cook
[state] => IL
[latitude] => 28.32
)
)
[kids] => Array
(
[0] => Array
(
[name] => Child One
[age] => 12
)
[1] => Array
(
[name] => Child Two
[age] => 4
)
)
)
当我通过命令控制台查询MongoDB时,我可以看到文档存储时对象完整,大括号和所有:
{
"_id" : ObjectId("4ea06851fe90d0662900000a"),
"name" : "Jason A",
"address" : {
"line1":"123 Main St"
"city" : "Chicago",
"zip" : "60611",
"country" : "US",
"longitude" : -81.59,
"state" : "IL",
"latitude" : 28.32
},
"kids" : [
{
"name" : "Child One",
"age" : 12
},
{
"name" : "Child Two",
"age" : "4"
}
]
}
如何通过PHP查询MongoDB并保持对象完好无损?