0

在 CakePHP 中,我试图将数据保存在这样的子文档中:

$mongo = $this->User->getDataSource();
$mongo->update($this->User, array(
    array(
        '_id' => $tweep['User']['_id'],
        'Services._id' => $tweep['User']['Services']['_id']
    ),
    array('Services.$.following' => $following)
));

但显然我做错了什么,因为它不起作用。

$following 是一个数组,我想保存在具有特定 ID 的服务下。

这是数据源方法: https ://github.com/ichikaway/cakephp-mongodb/blob/cake2.0/Model/Datasource/MongodbSource.php#L635

4

1 回答 1

2

使用 updateAll() 方法而不是 update()。

或者

使用 MongoDbCollection 对象。 https://github.com/ichikaway/cakephp-mongodb/wiki/How-to-get-MongoObject-or-MongoCollection-object

于 2011-07-08T03:06:44.407 回答