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

区间查询 默认使用AND在最后面元素加上OR  SELECT*FROM`weibo_user`WHERE (`id`>1OR`id`<3)
$map['id']=array(
 array('gt',1),
 array('lt',3),
   'OR'
);
组合查询  SELECT*FROM`weibo_user`WHERE`id`=1OR(username="bnbbs"ANDemail 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`=1OR(`id`=2)
$map['id']=array('eq',1);
$where['id']=array('eq',2);
$map['_complex']=$where;
$map['_logic']='OR';
统计查询count()SELECTCOUNT(*)AStp_count FROM`weibo_user`LIMIT1
最大查询max(id)SELECTMAX(id)AStp_max FROM`weibo_user`LIMIT1
最小查询min(id)SELECTMIN(id)AStp_min FROM`weibo_user`LIMIT1
平均值查询avg(id)  SELECTAVG(id)AStp_avg FROM`weibo_user`LIMIT1
求和查询sum(id)SELECTSUM(id)AStp_sum FROM`weibo_user`LIMIT1
动态查询
getByField(value)SELECT*FROM`weibo_user`WHERE`id`=1LIMIT1
getByField(value)SELECT*FROM`weibo_user`WHERE`username`='bnbbs'LIMIT1
getFieldByField(value)SELECT`id`FROM`weibo_user`WHERE`username`='bnbbs'LIMIT1
SQL查询query($sql)只读execute($sql)只写

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

当前文章:thinkphp区间查询组合查询复合查询动态查询SQL查询
网页路径:http://pwwzsj.com/article/jiiiop.html