聚合

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

max

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

min

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

count

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

avg

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

sum

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