Home >PHP Framework >ThinkPHP >What are the ThinkPHP queries for PHP?
1. Aggregation query
In applications, we often use some statistical data, such as the number of current users (or those who meet certain conditions), the points of all users, The user's average score, etc., ThinkPHP provides a series of built-in methods for these statistical operations.
Get the number of users:
Db::table('think_user')->count(); // 助手函数 db('user')->count();
2. Time query
Use the where method.
The method supports time comparison, for example:
// 大于某个时间 where('create_time','> time','2016-1-1'); // 小于某个时间 where('create_time','<= time','2016-1-1'); // 时间区间查询 where('create_time','between time',['2015-1-1','2016-1-1']);
3. Quick query
The quick query method is a multi-field same query condition The simplified writing method of can further simplify the writing of query conditions. Use | to split between multiple fields to represent OR query, and use & to split to represent AND query. The following query can be implemented, for example:
Db::table('think_user') ->where('name|title','like','thinkphp%') ->where('create_time&update_time','>',0) ->find();
The above is the detailed content of What are the ThinkPHP queries for PHP?. For more information, please follow other related articles on the PHP Chinese website!