本文介绍了PHP&游荡的蒙哥(Mongo in Vagrant),"消息为"BSON doc的大小为x字节,最大为0"的未捕获异常'MongoException'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在其中装有Mongo和PHP的Vagrant设置,但是每当我尝试在Mongo集合中运行简单的插入操作时,都会出现上述错误,

I've a Vagrant setup with Mongo and PHP within, but any time I try to run a simple insert into a Mongo collection, I get the above error,

Uncaught exception 'MongoException' with message 'size of BSON doc is 210 bytes, max is 0'

实际代码是

$mongo = new Mongo();
$mongo->newdb->drop();
$db = $mongo->newdb;
$collection = $db->newcollection;
$collection->insert(array ( "_id" => new MongoId("4ec1019f87484465ae4d777e"), "id" => 1));

几乎没有关于此错误的在线信息,并且几乎所有我的Vagrant设置都是在线说明的.有人知道为什么它会失败吗?

There's nearly no info about this error online, and near all my Vagrant setup is what's stated online to work. Anybody with an idea why it fails?

推荐答案

很抱歉,这是因为我已经安装了一个非常的Mongo旧版本,例如1.4,因为有一个游民配置错误.一旦解决了这个问题并安装了最新的版本(MongoDB shell版本:2.0.7),一切都变得很吸引人.谢谢您的帮助.

Sorry about that, this was down to a very old version of Mongo I had installed, something like 1.4, because of a Vagrant misconfiguration. Once I sorted that out and installed the most recent one (MongoDB shell version: 2.0.7), everything worked like a charm. Thanks for the help though.

这篇关于PHP&游荡的蒙哥(Mongo in Vagrant),"消息为"BSON doc的大小为x字节,最大为0"的未捕获异常'MongoException'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 02:39