我有这个文件:
{
"_id" : ObjectId("56db04fcf0aac2042ea63de4"),
"POST_ID" : 3,
"QA" : [
{
"Q_ID" : 1,
"ANSWERS" : [ ]
},
{
"Q_ID" : 2,
"ANSWERS" : [ ]
}
]
}
现在我想把$答案推到这个文件中
$answer = array('A_ID'=>$answer_id, 'ANSWER'=>$_POST['answer'], 'COMMENTS'=>array());
我试过了:
$collection->update(array('POST_ID'=>3),array('$push'=>array('QA.ANSWERS'=>$answer)),false,true);
给了我错误:
Catchable fatal error: Argument 3 passed to MongoCollection::update() must be of the type array, boolean given, called in /var/www/html/ProjectTest/post.php on line 30 and defined in /var/www/html/ProjectTest/include/Function Helper.php on line 126
我有办法做到这一点吗?