Wright 的个人博客 / 10 / 4 / 创建于 2年前
近期遇到一个问题,还请各位大神指教一下。
在使用模型查询的时候里面用了 withCount 这个方法进行统计数量,同时也用了 select 进行指定字段,结果出来后还是将所有字段给查了出来。
Users::query() ->withCount("emailLog") ->select("id","email_log_id","name") ->get() ->toArray();Copy
Users::query() ->withCount("emailLog") ->select("id","email_log_id","name") ->get() ->toArray();
各位大神请指教这是为什么呢?应该怎么解决?
本作品采用《CC 协议》,转载必须注明作者和本文链接
withCount 要用在 select 后面
先写 select 后 withcount
Users::query() ->select("id","email_log_id","name") ->withCount("emailLog") ->get() ->toArray();Copy
Users::query() ->select("id","email_log_id","name") ->withCount("emailLog") ->get() ->toArray();
我要举报该,理由是:
推荐文章: