模型where 变量值怎么变成字段值查询了 导致sql报错
$account = $request->account;
$user = $user::query();
$user->when(is_email($account), function ($query )use ($account) {
return $query->where('email', $account);
});
$user->when(is_number($account), function ($query )use ($account) {
return $query->where('phone', $account);
});
$user->first();
日志中看到执行的语句是
select * from `pe_users` where `email` = 32523351@qq.com limit 1
email没有单引号 就报错 这个怎么处理呀
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘@qq.com limit 1’ at line 1