大家好,像往常一样,感谢任何花时间阅读本文的人。
我正在尝试显示与已提出的问题相关的所有答案。我正在使用 Kohana 3。
到目前为止,我可以通过以下方式确定哪条记录的 vote_points 最高:
$best_id = DB::query(Database::SELECT, 'SELECT id FROM answers WHERE vote_points=(SELECT MAX(vote_points) FROM answers) AND question_id ='.$question->id)->execute();
而且,我收集了所有答案并通过将结果集放在 foreach 循环中来显示它们:
<?php foreach($question->answers->where('moderated', '=', 0)->where('deleted', '=', 0)->order_by('created_at', 'ASC')->find_all() as $answer): ?>
A bunch of display answer functions and divs~~~
我需要找到一种方法来确保首先显示带有 $best_id 的记录,并且只显示一次,而其余的答案由 created_at asc 显示和排序。
谢谢大家!