The following column Laravel Tutorial will introduce to you LaravelThe solution to modify the data to be the same as the original data, resulting in no sql execution, I hope it will be helpful to you Friends in need help!
$openid = "123"; // 微信openid User::WhereIn("id",['1','2','3'])->update([ 'openid' => $openid ]); $user = User::find(1); // 取消所有这个openid的绑定者 User::Where(['openid' => $openid])->update([ 'openid' => null ]); // 给1号用户绑定openid $user->openid = $openid; $user->save();
Question: openid = 123
How many are there?
Answer: One nothing.
##getDirty will return the
original of $user
(queried ones are not allowed to change) and
attributes (manually assigned values) are different.
$user->save () No modification will be performed.
, I noticed something was wrong. I thought it was laravel
or mysql
bug
The above is the detailed content of How to solve the problem that Laravel's modified data is the same as the original data, resulting in no SQL execution. For more information, please follow other related articles on the PHP Chinese website!