我正在尝试使用mongodb的Yii2进行更新查询。我做了以下查询:
$collection = Yii::$app->mongodb->getCollection('usermaster');
$arrUpdate = [
'firstName' => $fname,
'lastName' => $lname,
'email' => $email,
'is_visible' => $isvisibleUser,
'phoneNumber' => $phone,
'userName' => $uname,
];
$collection->update(['_id = 55a4957sd88423d10ea7c07d'],$arrUpdate);
但是firebug显示如下错误:
"NetworkError: 500 Internal Server Error - http://localhost/yii2angularseedmaster/frontend/web/category/corporateupdate?corpUserid=55a4957sd88423d10ea7c07d"
我的插入查询工作正常,但更新查询不工作。
请告诉我我的查询有什么问题
收集->更新([‘_id => $ id], arrUpdate美元);
你的代码应该是这样的
$collection = Yii::$app->mongodb->getCollection('usermaster');
$arrUpdate = [
'firstName' => $fname,
'lastName' => $lname,
'email' => $email,
'is_visible' => $isvisibleUser,
'phoneNumber' => $phone,
'userName' => $uname,
];
$collection->update(['_id' => $id],$arrUpdate);