public function setOrder($field, $desc = null)
    {
        if (!$field instanceof Field) {
            if (is_object($field)) {
                $this->_dsql()->order($field, $desc);

                return $this;
            }

            if (is_string($field) && strpos($field, ',') !== false) {
                $field = explode(',', $field);
            }
            if (is_array($field)) {
                if (!is_null($desc)) {
                    throw $this->exception('If first argument is array, second argument must not be used');
                }

                foreach (array_reverse($field) as $o) {
                    $this->setOrder($o);
                }

                return $this;
            }

            if (is_null($desc) && is_string($field) && strpos($field, ' ') !== false) {
                list($field, $desc) = array_map('trim', explode(' ', trim($field), 2));
            }

            /** @type Field $field */
            $field = $this->getElement($field);
        }

        $this->_dsql()->order($field, $desc);

        return $this;
    }
public function setOrder($field, $desc = null)
    {
        if (!$field instanceof Field) {
            if (is_object($field)) {
                $this->_dsql()->order($field, $desc);

                return $this;
            }

            if (is_string($field) && strpos($field, ',') !== false) {
                $field = explode(',', $field);
            }
            if (is_array($field)) {
                if (!is_null($desc)) {
                    throw $this->exception('If first argument is array, second argument must not be used');
                }

                foreach (array_reverse($field) as $o) {
                    $this->setOrder($o);
                }

                return $this;
            }

            if (is_null($desc) && is_string($field) && strpos($field, ' ') !== false) {
                list($field, $desc) = array_map('trim', explode(' ', trim($field), 2));
            }

            /** @type Field $field */
            $field = $this->getElement($field);
        }

        $this->_dsql()->order($field, $desc);

        return $this;
    }
public function setOrder ( $ field , $ desc = null ) { if ( ! $ field instanceof Field ) { if ( is_object ( $ field ) ) { $ this -> _dsql ( ) -> order ( $ field , $ desc ) ; return $ this ; } if ( is_string ( $ field ) && strpos ( $ field , ',' ) !== false ) { $ field = explode ( ',' , $ field ) ; } if ( is_array ( $ field ) ) { if ( ! is_null ( $ desc ) ) { throw $ this -> exception ( 'If first argument is array, second argument must not be used' ) ; } foreach ( array_reverse ( $ field ) as $ o ) { $ this -> setOrder ( $ o ) ; } return $ this ; } if ( is_null ( $ desc ) && is_string ( $ field ) && strpos ( $ field , ' ' ) !== false ) { list ( $ field , $ desc ) = array_map ( 'trim' , explode ( ' ' , trim ( $ field ) , 2 ) ) ; } /** @type Field $field */ $ field = $ this -> getElement ( $ field ) ; } $ this -> _dsql ( ) -> order ( $ field , $ desc ) ; return $ this ; }
Sets an order on the field. Field must be properly defined
Sets an order on the field . Field must be properly defined