数据库字段名:link_logs varchar 类型,存的是 referral_log 的 id 串,每个 id 用,号隔开,实际数据是这样的: 1,2,3,4,5
然后再 laravel 中更新的时候把这个直接取出来放到 whereIn 条件中 如果这样写:会导致只更新第一条就是 1 的 status,而我的目的是更新 12345 都要更新
$referralApply = ReferralApply::where('id', $id)->first();
ReferralLog::whereIn('id', [$referralApply->link_logs])->update(['status' => 1]);
这样 explode 一遍就不会,这是为什么呢?
$referralApply = ReferralApply::where('id', $id)->first();
$log_ids = explode(',', $referralApply->link_logs);
ReferralLog::whereIn('id', $log_ids)->update(['status' => 1]);