lumen + mongodb:如何更新组中的记录

时间:2018-12-10 12:28:02

标签: mongodb laravel lumen

我的代码如下,

foreach ($getEmails as $emails) {
                $update =[];
                if (isset($emails["suite_id"]) && $emails["suite_id"]) {
                    $emailSuiteId = explode(",", $emails["suite_id"]);
                    $update["suite_id"]= implode(",", array_unique(array_merge($emailSuiteId, $suiteIds)));
                }                 
                $update["updated_at"] = new \DateTime();
                $update["updated_by"] = $request->user_id;
                DB::connection('mongodb')->collection('email_message')
                ->Where('aid', (int)$emails['aid'])
                ->Where('email_account_id', (int)$request->email_account_id)->update($update);
            }

有什么方法可以在单个查询中更新记录,而不是在循环中更新记录?

请尽快给我答复。谢谢

0 个答案:

没有答案