Hello! It's a great pleasure to have you visit my blog.
It's truly a fateful encounter. If you are interested in Chinese goods, we can collaborate.
I can provide you with affordable Chinese products that you can sell in your country, thereby boosting our economic income.


If you are willing to cooperate, I hope to hear from you to discuss the opportunity for collaboration.
Here is my Email: t@29ym.com
Looking forward to connecting with you and embarking on this partnership together!

Thinkphp6某个字段相加得到总数助手函授用法

适用于tp5,tp6
方法 说明
count 统计数量,参数是要统计的字段名(可选)
max 获取最大值,参数是要统计的字段名(必须)
min 获取最小值,参数是要统计的字段名(必须)
avg 获取平均值,参数是要统计的字段名(必须)
sum 获取总分,参数是要统计的字段名(必须)
用法示例:

获取用户数:

Db::table(‘think_user’)->count();

// 助手函数

db(‘user’)->count();

或者根据字段统计:

Db::table(‘think_user’)->count(‘id’);

// 助手函数

db(‘user’)->count(‘id’);

获取用户的最大积分:

Db::table(‘think_user’)->max(‘score’);

// 助手函数

db(‘user’)->max(‘score’);

获取积分大于0的用户的最小积分:

Db::table(‘think_user’)->where(‘score>0’)->min(‘score’);

// 助手函数

db(‘user’)->where(‘score>0’)->min(‘score’);

获取用户的平均积分:

Db::table(‘think_user’)->avg(‘score’);

// 助手函数

db(‘user’)->avg(‘score’);

统计用户的总成绩:

Db::table(‘think_user’)->sum(‘score’);

// 助手函数

db(‘user’)->sum(‘score’);
发表新评论