User::where('foo', 10)->first();
select * from `users` where `foo` = 10
User::where('foo', '10')->first();
select * from `users` where `foo` = 10
User::where('foo', 'abc')->first();
select * from `users` where `foo` = 'abc'
laravel5.8
1
iyaozhen 2019-12-19 12:24:42 +08:00 via Android
MySQL 里面试过吗?我记得不区分 10 还是'10'
|
3
ylsc633 2019-12-19 12:38:23 +08:00
恭喜你 遇到了一个 建立索引,且用了索引字段,但不走索引的情况!
以后可能会被问到! 哈哈哈 |
4
chinvo 2019-12-19 14:21:39 +08:00 via iPhone
我记得 laravel 的 ORM 有个强制类型的参数,太就没用过有点记不清
|
5
zibber 2019-12-19 19:57:56 +08:00
User::where('foo', Db:raw("'10'"))->first();
|