【发布时间】:2023-02-11 02:36:57
【问题描述】:
我创建了 fc_forum_post 表,当此列等于 1 时,其中一列是 is_question 表示该行是问题当列等于 0 时,表示该行是答案。
现在我想用 status = 2 ether question 或 'answer' 对我的网格视图进行排序。
事实上,我想用另一个查询对查询进行排序。 是这样的:
$query = ForumPost::find() ->select([ 'forum_post.*', 'waiting' => ForumPost::find() ->select('COUNT(*)') ->where('forum_post.is_question = 0') ->andWhere('forum_post.status = 2') ]) ->joinWith(['category', 'user']) ->where(['forum_post.is_question' => 1]) ->orderBy([ 'waiting' => SORT_DESC 'forum_post.status' => SORT_DESC ]);
我已经为我尝试过这个查询网格视图.实际上,我想让answer count 列与该列一起排序。
| question title | answer count |
|---|---|
| title one | 4 |
| title twho | 3 |
**问题标题** = forum_post.is_question = 1
**答案计数** = forum_post.is_question = 0
如果您对更好地理解我的问题有任何疑问,请问我,我将不胜感激帮助我解决我的问题。
【问题讨论】: