thinkphp查询语句whereOr不能再添加where条件

浏览:4670 发布日期:2018/03/12 分类:求助交流
tp链式查询:
$record = db('activity_record')->join('think_activity','think_activity_record.activityid=think_activity.id','left')->field('think_activity_record.id,think_activity_record.activityid,think_activity_record.ishexiao,think_activity.title,think_activity.starttime,think_activity.endtime,think_activity.addname,think_activity.thumb,think_activity.logo,think_activity.unit,think_activity_record.openid')->where('think_activity_record.ishexiao',0)->whereOr('think_activity_record.ishexiao', 1)->where('think_activity_record.openid',$openid)->page($page,10)->select();



原生查询:
$record = Db::query("SELECT a.id,a.activityid,a.ishexiao,a.openid,b.title,b.starttime,b.endtime,b.addname,b.thumb,b.logo,b.unit FROM think_activity_record a LEFT JOIN think_activity b on a.activityid=b.id WHERE (a.ishexiao = 0 OR a.ishexiao = 1) AND a.openid ='".$openid."' LIMIT ".$num_start.",10;");

链式查询有 查询结果 一条数据(查出数据中openid和where条件中的openid不同)

原生查询无数据(正确)

查询的逻辑是记录表think_activity_record表的记录activityid等于活动表的id
查询的ishexiao字段是0或1且openid等于传过来的openid

我的问题是我链式查询是不是用错了为什么会有数据,应该是没数据的。
最佳答案
评论( 相关
后面还有条评论,点击查看>>