Update array of EmbeddedDocument

35 views
Skip to first unread message

Riccardo Coppola

unread,
Apr 19, 2012, 5:38:46 AM4/19/12
to yiimong...@googlegroups.com
Hi all,
I have a field in my collection that is an array of embedded documents. 
Now, I have to update an embedded document using one of it's properties as key for the query
In short, I can't use
$user->addresses[0]->city = 'New York';
but i'd like to use something like
$user->addresses['city': 'MyCity']->city = 'New York';

To update the embedded document with city = 'MyCity' with the new value 'New York'.

In mongo shell, i'd use the $ positional operator this way:
t.update( {'adresses.city':'MyCity'}, {$set:{'addresses.$.city': 'New York'}})
Is there a way to do it with YiiMongoDbSuite?
Thank you,
Riccardo
Reply all
Reply to author
Forward
0 new messages