开发者

Save data in MongoDB subdocument with CakePHP

In CakePHP I am trying to save data in a subdocument like this:

$mongo = $this-&g开发者_开发问答t;User->getDataSource();
$mongo->update($this->User, array(
    array(
        '_id' => $tweep['User']['_id'],
        'Services._id' => $tweep['User']['Services']['_id']
    ),
    array('Services.$.following' => $following)
));

But obviously I am doing something wrong as it doesn't work.

$following is an array that I would like to save under Services whith a specific id.

This is the datasource method: https://github.com/ichikaway/cakephp-mongodb/blob/cake2.0/Model/Datasource/MongodbSource.php#L635


use updateAll() method instead of update().

or

use MongoDbCollection Object. https://github.com/ichikaway/cakephp-mongodb/wiki/How-to-get-MongoObject-or-MongoCollection-object

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜