当前位置:asp编程网>技术教程>Php教程>  正文

thinkphp中and和or查询语句的写法

2017-05-22 09:00:33   来源:www.aspbc.com   作者:wangsdong   浏览量:2358   收藏
这里介绍thinkphp中两种条件and和or语句的写法

1、and条件的写法,它的写法比较简单
     $data['id'] = array('eq',3);
     $data['pid'] = array('eq',10);
     这句表达的意思是
     where id = 3 and pid = 10 这种写法

2、or条件的写法
  or条件的写法要分两种情况
  a、同一字段
     $data['id'] = array(array('eq',3),array('eq',10), 'or') ; 
     这句表达的意思是
     where id = 3 or id = 10 
  b、不同字段
     $where['name']  = array('like', '%aspbc.com%');
     $where['title']  = array('like','%aspbc.com%');
     $where['_logic'] = 'or';
     $data['_complex'] = $where;   //or条件完成
     $data['id']  = array('gt',1); //其他条件
     这句表达的意思是
     where (name like '%aspbc.com%' or title like '%aspbc.com%') and id =1;

原创文章,转载请注明来源www.aspbc.com,谢谢

上一篇: 无

下一篇: thinkphp中事务处理代码写法

关于我们-广告合作-联系我们-积分规则-网站地图

Copyright(C)2013-2017版权所属asp编程网