美文网首页
ThinkPHP框架where如何实现or查询

ThinkPHP框架where如何实现or查询

作者: lookphp | 来源:发表于2017-12-01 10:21 被阅读1022次

关于查询 where 中or的问题,可以使用下列表达式的写法:

$where = [
                'post.post_status'     => [ 'eq' , 1 ] ,
                'post.relation_id' => [ [ 'eq' , $relation_id] , [ 'eq' , 0 ] , [ 'EXP' , 'IS NULL' ] , 'or' ] ,
            ];

输出的结果为:

WHERE post.post_status=1 AND (post.relation_id=$relation_id OR post.relation_id=0 OR post.relation_id is null);

相关文章

网友评论

      本文标题:ThinkPHP框架where如何实现or查询

      本文链接:https://www.haomeiwen.com/subject/gfmbbxtx.html