温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

thinkphp 区间查询 组合查询 复合查询 动态查询 SQL查询

发布时间:2020-07-08 17:13:16 来源:网络 阅读:689 作者:高安宇 栏目:web开发
区间查询 默认使用AND 在最后面元素加上OR  SELECT * FROM `weibo_user` WHERE ( `id` > 1 OR `id` < 3 )
$map['id']=array(
  array('gt',1),
  array('lt',3),
    'OR'
);
组合查询  SELECT * FROM `weibo_user` WHERE `id` = 1 OR ( username = "bnbbs" AND email like "%bnbb%" )
$map['id']=array('eq',1);
$map['_string']='username = "bnbbs" AND email like "%bnbb%"';
$map['_logic']="OR";
请求字符串查询
$map['id']=array('eq',1);
$map['_query']='username=bnbbs&_logic=OR';
$map['_logic']='OR';
复合查询  SELECT * FROM `weibo_user` WHERE `id` = 1 OR ( `id` = 2 )
$map['id']=array('eq',1);
$where['id']=array('eq',2);
$map['_complex']=$where;
$map['_logic']='OR';
统计查询 count() SELECT COUNT(*) AS tp_count FROM `weibo_user` LIMIT 1
最大查询 max(id) SELECT MAX(id) AS tp_max FROM `weibo_user` LIMIT 1
最小查询 min(id) SELECT MIN(id) AS tp_min FROM `weibo_user` LIMIT 1
平均值查询 avg(id)  SELECT AVG(id) AS tp_avg FROM `weibo_user` LIMIT 1
求和查询 sum(id) SELECT SUM(id) AS tp_sum FROM `weibo_user` LIMIT 1
动态查询
getByField(value) SELECT * FROM `weibo_user` WHERE `id` = 1 LIMIT 1
getByField(value) SELECT * FROM `weibo_user` WHERE `username` = 'bnbbs' LIMIT 1
getFieldByField(value) SELECT `id` FROM `weibo_user` WHERE `username` = 'bnbbs' LIMIT 1
SQL查询 query($sql)只读 execute($sql)只写

var_dump($user->query('select * from weibo_user'));


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI