【发布时间】:2013-01-22 10:32:32
【问题描述】:
我正在尝试将 Codeigniter 与 codeigniter-mongodb-library/tree/v2 一起使用,以便与 mongo 连接并使用此结构更新文档:
{
"_id" : ObjectId("50fd8bd460e958aa38000002"),
"created_at" : 1358793684,
"updated_at" : 1358793684,
"is_active" : 0,
"memberships" : [
{
}
],
"first_models" : [
[ ]
],
"second_models" : [
[ ]
],
"pages" : [
[ ]
]
}
我想要的只是通过给定 _id 来更新一些文档。特别是我需要在“first_models”数组中添加元素。在我的 Codeigniter 模型中,我称之为:
$result = $this->mongo_db
->push(array('_id' => '50fd8bd460e958aa38000002'),array('first_models' => array('Some text here')))
->update($this->collections['sites']);
我在尝试更新一个特定文档时收到此错误:
Mod on _id not allowed
似乎与给定的_id有些冲突...我遗漏了一些东西,我不知道是什么:( 我正在使用带有 Codeigniter 2.1.3、PHP5.4 和 Apache2 的 Mongodb 2.2.2。
【问题讨论】:
标签: php codeigniter mongodb codeigniter-2 mongodb-php