聚合

ORM 还提供了各种聚合方法,比如 count, max,min, avg,还有 sum。你可以在构造查询后调用任何方法:

max

$max = TestUserListModel::create()->max('age');

min

$min = TestUserListModel::create()->min('age');

count

// count 不必传字段名
$count = TestUserListModel::create()->count();

avg

$avg = TestUserListModel::create()->avg('age');

sum

$sum = TestUserListModel::create()->sum('age');