mongodb php 删除,MongoDB / PHP:从数组中删除元素
問候,
我有以下MongoDB對象:
{
"_id": ObjectId("4d0e28938b012fe28754715a"),
"notifications": {
"0": {
"type": "privateMessage",
"fromUname": "Eamorr2",
"time": 1292773522,
"id": "1lfw70h789u13a1e67pv"
},
"1": {
"type": "privateMessage",
"fromUname": "Eamorr2",
"time": 1292773522,
"id": "iwoidjsoskqp23nlwof"
}
},
"toUname": "Eamorr"
}
我正在嘗試刪除元素0,留下我:
{
"_id": ObjectId("4d0e28938b012fe28754715a"),
"notifications": {
"0": {
"type": "privateMessage",
"fromUname": "Eamorr2",
"time": 1292773522,
"id": "iwoidjsoskqp23nlwof"
}
},
"toUname": "Eamorr"
}
這是我嘗試過的(在PHP中),但無濟于事:
$customerNotifications->update(array('toUname'=>$uname),array('$pull'=>array('notifications'=>$key)));
但它沒有用,我現在完全陷入困境.
任何幫助非常感謝.提前致謝,
新人創作打卡挑戰賽發博客就能抽獎!定制產品紅包拿不停!總結
以上是生活随笔為你收集整理的mongodb php 删除,MongoDB / PHP:从数组中删除元素的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 今天打广告。
- 下一篇: php+当前+日期+函数是,php时间日