19 declare(strict_types=1);
24 string $direction =
"asc",
25 bool $sort_by_status =
false 28 $join_str =
"LEFT JOIN (SELECT (ROUND(AVG(rating), 1) * 10000 + COUNT(rating)) as rating, obj_id FROM il_rating GROUP BY obj_id) AS average ON average.obj_id = record.id";
29 $select_str =
" average.rating AS field_{$this->getId()},";
32 $sql_obj->setSelectStatement($select_str);
33 $sql_obj->setJoinStatement($join_str);
34 $sql_obj->setOrderStatement(
"field_{$this->getId()} " . $direction .
", ID ASC");
46 if (!$sort_field instanceof $this) {
47 $join_str =
"LEFT JOIN (SELECT (ROUND(AVG(rating), 1) * 10000 + COUNT(rating)) as rating, obj_id FROM il_rating GROUP BY obj_id) AS average ON average.obj_id = record.id";
50 $where_additions =
" AND average.rating >= " .
$ilDB->quote($filter_value * 10000,
'integer');
53 $sql_obj->setWhereStatement($where_additions);
55 if (isset($join_str)) {
56 $sql_obj->setJoinStatement($join_str);
getRecordQuerySortObject(string $direction="asc", bool $sort_by_status=false)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getRecordQueryFilterObject( $filter_value="", ?ilDclBaseFieldModel $sort_field=null)