duanhuau567787 2013-03-08 03:18
浏览 64
已采纳

如何强制PHP Mongo驱动程序将结果作为对象而不是数组返回

I am using PHP Mongo extension to connect to Mongo DB server. The problem is that even though I insert the values into Mongo DB as objects, I am always getting the results in Array format when I use find or findOne in PHP. I found it really ugly and hacky.

Is there a way to make PHP retain the original structure as it is in Mongo DB ?

  • 写回答

1条回答 默认 最新

  • douzhigan1687 2013-04-22 22:07
    关注

    This is the same problem as raw JSON has in PHP, which is why json_decode() has an option to get returned results as array (defaulting being an object).

    Currently (version 1.3.7 and 1.4.0-dev) do not have such option. We have talked about adding that option, and I just created a tracking ticket for it now, which will potentially be fixed later in the 1.4.x series.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#java#的问题,请各位专家解答!
  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验
  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
  • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
  • ¥30 求解达问题(有红包)
  • ¥15 请解包一个pak文件