The operation you seem to want is update
$db->apps->update(
array('_id' => $update['_id']),
array('$push' => array('keys.gcm_android' => $gcm_android))
);
But is un-clear what you want your end result to be. This would produce the following:
{
"_id" : ObjectId("532aa3d15fcd8ecb9ae23567"),
"id" : "dfK15ale12",
"keys" : {
"gcm_key" : "abc",
"app_secret" : "123",
"gcm_android" : [
123
]
}
}
Assuming that you had value 123
in your $gcm_android
variable. If you have an array then look at $pushAll.
If you are just looking to add another property to keys then use $set:
$db->apps->update(
array('_id' => $update['_id']),
array('set' => array('keys.gcm_android' => $gcm_android))
);
Where this is your result:
{
"_id" : ObjectId("532aa3d15fcd8ecb9ae23567"),
"id" : "dfK15ale12",
"keys" : {
"gcm_key" : "abc",
"app_secret" : "123",
"gcm_android" : 123
}
}