tp 3.2 组合查询, 字符串模式查询
Posted 小小强学习网
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了tp 3.2 组合查询, 字符串模式查询相关的知识,希望对你有一定的参考价值。
$User = M("User"); // 实例化User对象
$map[‘id‘] = array(‘neq‘,1);
$map[‘name‘] = ‘ok‘;
$map[‘_string‘] = ‘status=1 AND score>10‘;
$User->where($map)->select();
最后转化为:
( `id` != 1 ) AND ( `name` = ‘ok‘ ) AND ( status=1 AND score>10 )
2
$map[‘id‘] = array(‘gt‘,‘100‘);
$map[‘_query‘] = ‘status=1&score=100&_logic=or‘;
转化为:
`id`>100 AND (`status` = ‘1‘ OR `score` = ‘100‘)
3
$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%‘) )
来源:http://document.thinkphp.cn/manual_3_2.html#combine_query
以上是关于tp 3.2 组合查询, 字符串模式查询的主要内容,如果未能解决你的问题,请参考以下文章
TP5报如下的错误 Indirect modification of overloaded element of thinkpaginatorCollection has no effect(代码片段