发布时间:2018-04-11 编辑:钰歆博客 阅读(82)
1.Thinkphp查询is null数据,写法如下:
$where['status']=array('EXP','IS NULL');
2.thinkphp查询条件怎么样查询表中一个字段大于另一个字段的记录
如表中有a,b两个字段,我想要查询a大于b的记录,条件语句该怎么写呢
$map['_string'] = 'a > b';
$map['intention_dk']=1;
//多条件
$where = "(uid = 1 OR name like %管理员% )";
$map['_string'] = $where;
3.查询不是null字段
$bmap['lock']=array('neq','');
4.假如表中city字段,值为0501,0502,0503,0504,0505,0506,0507,501,而你需要用501值精准搜索出只含有501的某条记录,那么就可以写成如下:
$where['_string'] = '`city` = 051'; //只有一个
$where['_string'] .= ' OR `city` LIKE "051,%"'; //在首位
$where['_string'] .= ' OR `city` LIKE "%,051"'; //在尾部
$where['_string'] .= ' OR `city` LIKE "%,051,%"'; //在中间
5.复合搜索
$where['name'] = array('like', '%thinkphp%');
$where['title'] = array('like','%thinkphp%');
$where['_logic'] = 'or';
$map['_complex'] = $where;
$map['id'] = array('gt',1);
查询条件是
( id > 1) AND ( ( name like '%thinkphp%') OR ( title like '%thinkphp%') )
标签:
下一篇:缓存方式、静态页面