MongoException: zero-length keys are not allowed, did you use $ with double quotes?

后端 未结 2 1720
没有蜡笔的小新
没有蜡笔的小新 2021-01-02 23:51

I\'m using symfony2 and mongodb, until today, everything is OK, but I create a new document, and suddenly, appears this error :

\"MongoException: zero

2条回答
  •  渐次进展
    2021-01-03 00:13

    It could be that you're trying to persist an object private attribute.

    If that's not the case a good way to debug is to shut off the zero-length key check so that you can actually debug by checking what it's being written into mongo.

    zero-length keys are not allowed, did you use $ with double quotes?

    Code: 1

    You tried to save "" as a key. You generally should not do this. "" can mess up subobject access and is used by MongoDB internally. However, if you really want, you can set mongo.allow_empty_keys to true in your php.ini file to override this sanity check. If you override this, it is highly recommended that you set error checking to strict to avoid string interpolation errors.

    http://php.net/manual/en/mongo.configuration.php#ini.mongo.allow-empty-keys

提交回复
热议问题