我正在尝试在流明框架中运行以下查询:
SELECT * FROM user WHERE (username = $username OR email = $username) AND password = $password AND flag = 1;
我的流明代码:
$login = User::where('pass', '=', md5($pass))
->where('flag', '=', $flag)
->where('username', '=', $username)
->orWhere('email', '=', $username)->first();
不知何故,这段代码总是返回 true 并绕过登录。该查询有什么问题?
当我orWhere
从查询中删除时,它非常适合用户名。