我想知道 MongoDB 中“客户服务”文档的最佳布局是什么。我想过这样的事情,但不确定。
{
"userid":(MONGODBUSERID),
"subject":"subjectofissue",
"issue":"issue that the user has",
"replies":[{
"whoreplied":"staff/customer",
"uid":"userid of replier",
"msg":"msg of reply"
}]
}
这是最好的方法吗?如果是这样,我将如何使用 PHP 更新回复数组?我需要插入回复数组而不覆盖过去的回复。
我绑了这个但得到了以下错误
致命错误:未捕获的异常“MongoException”,消息“不允许使用零长度的键,您是否使用带有双引号的 $?” 在 /home/MYSITE/public_html/core.php:347 堆栈跟踪:
我的代码
$array = array(
"$push" => array(
"replies" => array(
"whoreplied" => "user",
"uid" => new MongoId($this->data['uid']),
"msg" => $this->data['issue']
)
)
);
$collection->update(array(
"_id" => new MongoId($this->data['customerID'])
), $array);