如何做到這一點(diǎn):Users::whereNotIn('user_id', [$all_users])->update(['disabled' => 1]); 產(chǎn)生這個(gè)正確的查詢: update usersset disabled= 1, users. updated_at= '2020-01-03 14:11:09' 其中user_id不在 ('642','532','539','588','488','601')我無法擺脫斜線。字符串是這樣構(gòu)建的: $all_users=$all_users.$user_id->id."','";如果我打印 $all_users 字符串,它會(huì)正確打印,見下文 echo $all_users; 產(chǎn)生:'642','532','539','588','488','601'用戶::whereNotIn('user_id', [addslashes($all_users)])->update(['disabled' => 1]); 產(chǎn)生:更新users集disabled= 1, users. updated_at= '2020-01-03 13:53:02' 其中user_id不在('\'642\',\'532\',\'539\',\'588\',\'488\',\' 601\'')用戶::whereNotIn('user_id', [$all_users])->update(['disabled' => 1]); 產(chǎn)生:更新users集disabled= 1, users. updated_at= '2020-01-03 14:11:09' 其中user_id不在('\'642\',\'532\',\'539\',\'588\',\'488\',\' 601\'')//我也試過這個(gè) //Users::whereNotIn('user_id', [$all_users])->update(['disabled' => 1]); //Users::whereNotIn('user_id', [removeslashes($all_users)])->update(['disabled' => 1]); //Users::whereNotIn('user_id', [addslashes($all_users)])->update(['disabled' => 1]); //Users::whereNotIn('user_id', [str_replace("","\", $all_users)])->update(['disabled' => 1]);謝謝 !
1 回答

阿波羅的戰(zhàn)車
TA貢獻(xiàn)1862條經(jīng)驗(yàn) 獲得超6個(gè)贊
傳遞數(shù)組而不是字符串
$all_users[]=$user_id->id;
Users::whereNotIn('user_id', $all_users)->update(['disabled' => 1]);
- 1 回答
- 0 關(guān)注
- 160 瀏覽
添加回答
舉報(bào)
0/150
提交
取消