Classes/Service/OrderByService.php
public static function getOrderByString($orderBy, $tablename)
    {
        if (isset($orderBy) && !empty($orderBy)) {
            $cleanOrderByParts = [];
            $tableColumns = $GLOBALS['TCA'][$tablename]['columns'];
            $orderByParts = GeneralUtility::trimExplode(',', $orderBy);
            foreach ($orderByParts as $part) {
                $subparts = GeneralUtility::trimExplode(' ', $part);
                if (count($subparts) === 1) {
                    if (is_array($tableColumns[$subparts[0]])) {
                        $cleanOrderByParts[] = $subparts[0];
                    }
                } elseif (count($subparts) === 2) {
                    if (is_array($tableColumns[$subparts[0]]) && ($subparts[1] === 'ASC' || $subparts[1] === 'DESC')) {
                        $cleanOrderByParts[] = $subparts[0] . ' ' . $subparts[1];
                    }
                }
            }

            return implode(',', $cleanOrderByParts);
        }

        return '';
    }
public static function getOrderByString($orderBy, $tablename)
    {
        if (isset($orderBy) && !empty($orderBy)) {
            $cleanOrderByParts = [];
            $tableColumns = $GLOBALS['TCA'][$tablename]['columns'];
            $orderByParts = GeneralUtility::trimExplode(',', $orderBy);
            foreach ($orderByParts as $part) {
                $subparts = GeneralUtility::trimExplode(' ', $part);
                if (count($subparts) === 1) {
                    if (is_array($tableColumns[$subparts[0]])) {
                        $cleanOrderByParts[] = $subparts[0];
                    }
                } elseif (count($subparts) === 2) {
                    if (is_array($tableColumns[$subparts[0]]) && ($subparts[1] === 'ASC' || $subparts[1] === 'DESC')) {
                        $cleanOrderByParts[] = $subparts[0] . ' ' . $subparts[1];
                    }
                }
            }

            return implode(',', $cleanOrderByParts);
        }

        return '';
    }
public static function getOrderByString ( $ orderBy , $ tablename ) { if ( isset ( $ orderBy ) && ! empty ( $ orderBy ) ) { $ cleanOrderByParts = [ ] ; $ tableColumns = $ GLOBALS [ 'TCA' ] [ $ tablename ] [ 'columns' ] ; $ orderByParts = GeneralUtility :: trimExplode ( ',' , $ orderBy ) ; foreach ( $ orderByParts as $ part ) { $ subparts = GeneralUtility :: trimExplode ( ' ' , $ part ) ; if ( count ( $ subparts ) === 1 ) { if ( is_array ( $ tableColumns [ $ subparts [ 0 ] ] ) ) { $ cleanOrderByParts [ ] = $ subparts [ 0 ] ; } } elseif ( count ( $ subparts ) === 2 ) { if ( is_array ( $ tableColumns [ $ subparts [ 0 ] ] ) && ( $ subparts [ 1 ] === 'ASC' || $ subparts [ 1 ] === 'DESC' ) ) { $ cleanOrderByParts [ ] = $ subparts [ 0 ] . ' ' . $ subparts [ 1 ] ; } } } return implode ( ',' , $ cleanOrderByParts ) ; } return '' ; }
Returns the orderBy statement for database connection

@param string $orderBy
@param string $tablename

@return string
Returns the orderBy statement for database connection