베스트 댓글을 확인하기 위해 문서에 달린 댓글들의 각 추천수 중 제일 높은 값을 확인해야 하는 쿼리가 필요합니다.
추천 액션 직후 확인하는 작업을 수행하도록 해보려고 합니다.
$comment_srl = Context::get('target_srl');
$oCommentModel = getModel('comment');
$oComment = $oCommentModel->getComment($comment_srl, FALSE, FALSE);
$args->document_srl = $oComment->get('document_srl');
$cvotecount = ?????? ; // 쿼리 파일을 애드온에 업로드 하려 합니다.
쿼리파일 xml 이 필요합니다.
여러 댓글 중 추천수가 가장 높은 숫자를 $cvotecount 에담아야 합니다. 여러댓글 중 추천이 하나도 없다면 0이 담기구요.
문서의 댓글을 불러오는 쿼리는
<query id="getComment" action="select">
<tables>
<table name="comments" />
</tables>
<columns>
<column name="*" />
</columns>
<conditions>
<condition operation="equal" column="document_srl" var="document_srl" filter="number" notnull="notnull" />
</conditions>
</query>
이렇게 하는게 아닐까 하는 생각이 듭니다.
아마도 이렇게 쿼리하면 해당 문서의 댓글이 배열에 모두 담길 것 같은데요. 여기서 추천수 중에 제일 큰 값을 쏙 빼내야 할 것 같습니다.
<column name="*" />
<column name="comments.voted_count" />
여기를 고치면 추천수 컬럼만 가지고 오겠군요.....