Yii2:- 使用 mongodb 的更新查询更新记录

Yii2:- update record using update query for mongodb

我正在尝试使用 Yii2 为 mongodb 进行更新查询。我提出以下查询:

$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"

我的插入查询工作正常,但更新查询不工作。

请告诉我我的查询有什么问题。

$collection->update(['_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);