tp5 查询field使用函数问题

浏览:11090 发布日期:2018/03/12 分类:求助交流 关键字: field tp5 thinkphp5 mysql查询
Db::name('table')->where('id', 1)->field("*, if(substr(sn,1,2)='SY',1,0) as type")->select();tp翻译出来的查询语句是这样的SELECT *,  if(substr(sn,`1`,2)='SY',0) as type FROM `table` where id =
 1
其中1 被识别成了字段`1` 而且if语句也错了。



已解决:$field = ["*", "if(substr(sn,1,2)='SY',1,0) as type"];
最佳答案
评论( 相关
后面还有条评论,点击查看>>