尝试从我的数据库中获取描述.查询返回结果,但我想命令结果只显示投票率最高的结果.
投票应按upvoted
列减去的downvoted
列计算
$description = UnitDescription::find() ->where(['id_unit' => $model->id]) ->orderBy([ 'upvoted - downvoted' => SORT_DESC //Need this line to be fixed ]) ->one();
我希望有人可能有办法写这部分查询 - 谢谢
你应该尝试:
$description = UnitDescription::find() ->where(['id_unit' => $model->id]) ->orderBy(['(upvoted - downvoted)' => SORT_DESC]) ->one();