private function getEscapedSortorder($name, $prefix = 'r')
    {
        $order = '';

        $separatedOrders = $this->getOrderBys($name);

        $totalOrderByElements = count($separatedOrders);

        foreach ($separatedOrders as $index => $name) {
            list($name, $asc) = $this->getSortOrder($name);

            // If we don't have a name, we can't determine a sortorder.
            if (empty($name)) {
                return false;
            }
            if (strpos($name, 'RAND') !== false) {
                $order .= $name;
            } elseif ($prefix !== false) {
                $order .= $this->app['db']->quoteIdentifier($prefix . '.' . $name);
            } else {
                $order .= $this->app['db']->quoteIdentifier($name);
            }

            if (! $asc) {
                $order .= ' DESC';
            }

            if ($this->isNotLastItemInArray($totalOrderByElements, $index)) {
                $order .= ',';
            }
        }

        return $order;
    }
private function getEscapedSortorder($name, $prefix = 'r')
    {
        $order = '';

        $separatedOrders = $this->getOrderBys($name);

        $totalOrderByElements = count($separatedOrders);

        foreach ($separatedOrders as $index => $name) {
            list($name, $asc) = $this->getSortOrder($name);

            // If we don't have a name, we can't determine a sortorder.
            if (empty($name)) {
                return false;
            }
            if (strpos($name, 'RAND') !== false) {
                $order .= $name;
            } elseif ($prefix !== false) {
                $order .= $this->app['db']->quoteIdentifier($prefix . '.' . $name);
            } else {
                $order .= $this->app['db']->quoteIdentifier($name);
            }

            if (! $asc) {
                $order .= ' DESC';
            }

            if ($this->isNotLastItemInArray($totalOrderByElements, $index)) {
                $order .= ',';
            }
        }

        return $order;
    }
private function getEscapedSortorder ( $ name , $ prefix = 'r' ) { $ order = '' ; $ separatedOrders = $ this -> getOrderBys ( $ name ) ; $ totalOrderByElements = count ( $ separatedOrders ) ; foreach ( $ separatedOrders as $ index => $ name ) { list ( $ name , $ asc ) = $ this -> getSortOrder ( $ name ) ; // If we don't have a name, we can't determine a sortorder. if ( empty ( $ name ) ) { return false ; } if ( strpos ( $ name , 'RAND' ) !== false ) { $ order .= $ name ; } elseif ( $ prefix !== false ) { $ order .= $ this -> app [ 'db' ] -> quoteIdentifier ( $ prefix . '.' . $ name ) ; } else { $ order .= $ this -> app [ 'db' ] -> quoteIdentifier ( $ name ) ; } if ( ! $ asc ) { $ order .= ' DESC' ; } if ( $ this -> isNotLastItemInArray ( $ totalOrderByElements , $ index ) ) { $ order .= ',' ; } } return $ order ; }
Get an escaped sortorder for use in SQL, from a fieldname like 'title' or '-id'.

for example, -id returns `r`.`id` DESC

@param string $name
@param string $prefix

@return string
Get an escaped sortorder for use in SQL from a fieldname like title or - id .