src/DreamCommerce/ShopAppstoreLib/Resource.php
public function order($expr)
    {
        $matches = array();

        $expr = (array)$expr;

        $result = array();

        foreach($expr as $e) {
            // basic syntax, with asc/desc suffix
            if (preg_match('/([a-z_0-9.]+) (asc|desc)$/i', $e)) {
                $result[] = $e;
            } else if (preg_match('/([\+\-]?)([a-z_0-9.]+)/i', $e, $matches)) {

                // alternative syntax - with +/- prefix
                $subResult = $matches[2];
                if ($matches[1] == '' || $matches[1] == '+') {
                    $subResult .= ' asc';
                } else {
                    $subResult .= ' desc';
                }
                $result[] = $subResult;
            } else {
                // something which should never happen but take care [;
                throw new \RuntimeException('Cannot understand ordering expression', ResourceException::ORDER_NOT_SUPPORTED);
            }
        }

        $this->order = $result;

    }
public function order($expr)
    {
        $matches = array();

        $expr = (array)$expr;

        $result = array();

        foreach($expr as $e) {
            // basic syntax, with asc/desc suffix
            if (preg_match('/([a-z_0-9.]+) (asc|desc)$/i', $e)) {
                $result[] = $e;
            } else if (preg_match('/([\+\-]?)([a-z_0-9.]+)/i', $e, $matches)) {

                // alternative syntax - with +/- prefix
                $subResult = $matches[2];
                if ($matches[1] == '' || $matches[1] == '+') {
                    $subResult .= ' asc';
                } else {
                    $subResult .= ' desc';
                }
                $result[] = $subResult;
            } else {
                // something which should never happen but take care [;
                throw new \RuntimeException('Cannot understand ordering expression', ResourceException::ORDER_NOT_SUPPORTED);
            }
        }

        $this->order = $result;

    }
public function order ( $ expr ) { $ matches = array ( ) ; $ expr = ( array ) $ expr ; $ result = array ( ) ; foreach ( $ expr as $ e ) { // basic syntax, with asc/desc suffix if ( preg_match ( '/([a-z_0-9.]+) (asc|desc)$/i' , $ e ) ) { $ result [ ] = $ e ; } else if ( preg_match ( '/([\+\-]?)([a-z_0-9.]+)/i' , $ e , $ matches ) ) { // alternative syntax - with +/- prefix $ subResult = $ matches [ 2 ] ; if ( $ matches [ 1 ] == '' || $ matches [ 1 ] == '+' ) { $ subResult .= ' asc' ; } else { $ subResult .= ' desc' ; } $ result [ ] = $ subResult ; } else { // something which should never happen but take care [; throw new \ RuntimeException ( 'Cannot understand ordering expression' , ResourceException :: ORDER_NOT_SUPPORTED ) ; } } $ this -> order = $ result ; }
order record by column
@param string $expr syntax:
<field> (asc|desc)
or
(+|-)<field>
@return $this
@throws \RuntimeException
order record by column