where参数给的是int类型,为什么sql监控出来变成string类型?
DB::table('表名')
->where('docId',intval($docId))
->where('states',1)
->orderBy('id', 'desc') //发布日期
->skip(0)
->take(20)
->select('id','nickName')->get();
通过DB::getQueryLog()跟踪出来的查询语句:
[2015-06-08 21:10:39] production.INFO: [{"query":"select top 20 [id], [nickName] from [表名] where [docId] = ? and [states] = ? order by [id] desc","bindings":[145439,1],"time":243.35}] [] []
上面docId和states对应的值是int类型,但是sqlserver监视器查出来的确实string,如下:
select top 20 [id], [nickName] from [表名] where [docId] = '145439' and [states] = '1' order by [id] desc
这是查询语句直接导致不走索引,性能低啊。 请高手回答下我的疑问吧。
->where('docId',intval($docId))
->where('states',1)
->orderBy('id', 'desc') //发布日期
->skip(0)
->take(20)
->select('id','nickName')->get();
通过DB::getQueryLog()跟踪出来的查询语句:
[2015-06-08 21:10:39] production.INFO: [{"query":"select top 20 [id], [nickName] from [表名] where [docId] = ? and [states] = ? order by [id] desc","bindings":[145439,1],"time":243.35}] [] []
上面docId和states对应的值是int类型,但是sqlserver监视器查出来的确实string,如下:
select top 20 [id], [nickName] from [表名] where [docId] = '145439' and [states] = '1' order by [id] desc
这是查询语句直接导致不走索引,性能低啊。 请高手回答下我的疑问吧。
2 个回复
wuangv - you win
赞同来自: kwaiyboy
kwaiyboy
赞同来自: