码迷,mamicode.com
首页 > 其他好文 > 详细

tp 3.2 组合查询, 字符串模式查询

时间:2017-11-26 18:46:45      阅读:314      评论:0      收藏:0      [点我收藏+]

标签:man   use   where   logic   and   com   name   http   nbsp   

$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 组合查询, 字符串模式查询

标签:man   use   where   logic   and   com   name   http   nbsp   

原文地址:http://www.cnblogs.com/xqschool/p/7899588.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!