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
精彩评论