protected function order_sql(?string $fieldname = null, string $order = 'ASC', ?string $tablealias = null) {

        if (!$tablealias) {
            $tablealias = 'analysable';
        }

        if ($order != 'ASC' && $order != 'DESC') {
            throw new \coding_exception('The order can only be ASC or DESC');
        }

        $ordersql = ' ORDER BY (CASE WHEN aua.timeanalysed IS NULL THEN 0 ELSE aua.timeanalysed END) ASC';
        if ($fieldname) {
            $ordersql .= ', ' . $tablealias . '.' . $fieldname .' ' . $order;
        }

        return $ordersql;
    }
protected function order_sql(?string $fieldname = null, string $order = 'ASC', ?string $tablealias = null) {

        if (!$tablealias) {
            $tablealias = 'analysable';
        }

        if ($order != 'ASC' && $order != 'DESC') {
            throw new \coding_exception('The order can only be ASC or DESC');
        }

        $ordersql = ' ORDER BY (CASE WHEN aua.timeanalysed IS NULL THEN 0 ELSE aua.timeanalysed END) ASC';
        if ($fieldname) {
            $ordersql .= ', ' . $tablealias . '.' . $fieldname .' ' . $order;
        }

        return $ordersql;
    }
protected function order_sql ( ? string $ fieldname = null , string $ order = 'ASC' , ? string $ tablealias = null ) { if ( ! $ tablealias ) { $ tablealias = 'analysable' ; } if ( $ order != 'ASC' && $ order != 'DESC' ) { throw new \ coding_exception ( 'The order can only be ASC or DESC' ) ; } $ ordersql = ' ORDER BY (CASE WHEN aua.timeanalysed IS NULL THEN 0 ELSE aua.timeanalysed END) ASC' ; if ( $ fieldname ) { $ ordersql .= ', ' . $ tablealias . '.' . $ fieldname . ' ' . $ order ; } return $ ordersql ; }
Returns the order by clause.

@param  string|null $fieldname  The field name
@param  string      $order      'ASC' or 'DESC'
@param  string|null $tablealias The table alias of the field
@return string
Returns the order by clause .