- ·上一篇文章:thinkphp中事务处理代码写法
- ·下一篇文章:PHP生成唯一标识符token代码
thinkphp中and和or查询语句的写法
这里介绍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', '%K88.NET%');
$where['title'] = array('like','%K88.NET%');
$where['_logic'] = 'or';
$data['_complex'] = $where; //or条件完成
$data['id'] = array('gt',1); //其他条件
这句表达的意思是
where (name like '%K88.NET%' or title like '%K88.NET%') and id =1;
原创文章,转载请注明来源www.K88.NET,谢谢
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', '%K88.NET%');
$where['title'] = array('like','%K88.NET%');
$where['_logic'] = 'or';
$data['_complex'] = $where; //or条件完成
$data['id'] = array('gt',1); //其他条件
这句表达的意思是
where (name like '%K88.NET%' or title like '%K88.NET%') and id =1;
原创文章,转载请注明来源www.K88.NET,谢谢
thinkphp中and和or查询语句的写法