Tp field 字段是可以添加函数的

$info = M('Order')->alias('a')
->field('count(DISTINCT(a.order_user_id)) as buy_user_num,count(*) as sum,sum(a.close_pay) as order_sum')
->join('__APP_TYPE_EDITION__ as b on b.type_id=a.type_id and b.edition_id=a.edition_id')
->join('__USER__ as c on c.user_id=a.order_user_id')
->where($where)
->order($order)
->find();
统计订单 的购买用户数,订单数,订单金额数
原文地址:https://www.cnblogs.com/already/p/5997464.html