1、聚合查询
在应用中我们经常会用到一些统计数据,例如当前所有(或者满足某些条件)的用户数、所有用户的积分、用户的平均成绩等等,ThinkPHP为这些统计操作提供了一系列的内置方法。
获取用户数:
1
2
3
Db::table(think_user)->count();
// 助手函数
db(user)->count();
2、时间查询
使用 where方法。
1
2
3
4
// 大于某个时间
where(create_time,> time,2016-1-1);
// 小于某个时间
where(create_time,<p><strong>3、快捷查询</strong></p><p>快捷查询方式是一种<strong>多字段相同查询条件</strong>的简化写法,可以进一步简化查询条件的写法,在多个字段之间用 | 分割表示OR查询,用 & 分割表示AND查询,可以实现下面的查询,例如:</p><pre class="brush:php;toolbar:false">Db::table(think_user) ->where(name|title,like,thinkphp%) ->where(create_time&update_time,>,0) ->find();
以上就是PHP的ThinkPHP查询有哪些的详细内容,更多请关注php中文网其它相关文章!