protected function parse_order( $alias = 'q' ) {

		if ( ! is_array( $this->args['order'] ) && $this->args['order'] === 'rand' ) {
			return new Order( Order::RAND );
		} elseif ( ! is_array( $this->args['order'] ) ) {
			throw new \InvalidArgumentException( "Order must either be 'rand' or an array of columns to directions." );
		}

		$white_list = $this->table->get_columns();

		foreach ( $this->args['order'] as $column => $direction ) {

			$direction = strtoupper( $direction );

			if ( ! in_array( $direction, array( Order::ASC, Order::DESC ) ) ) {
				throw new \InvalidArgumentException( "Invalid order direction $direction for column $column." );
			}

			$column = $this->translate_order_by_to_column_name( $column );

			if ( ! isset( $white_list[ $column ] ) ) {
				throw new \InvalidArgumentException( "Invalid order column $column." );
			}

			$column = "{$alias}.$column";

			if ( ! isset( $order ) ) {
				$order = new Order( $column, $direction );
			} else {
				$order->then( $column, $direction );
			}
		}

		if ( isset( $order ) ) {
			return $order;
		} else {
			return new Order( "{$alias}.{$this->table->get_primary_key()}", Order::ASC );
		}
	}
protected function parse_order( $alias = 'q' ) {

		if ( ! is_array( $this->args['order'] ) && $this->args['order'] === 'rand' ) {
			return new Order( Order::RAND );
		} elseif ( ! is_array( $this->args['order'] ) ) {
			throw new \InvalidArgumentException( "Order must either be 'rand' or an array of columns to directions." );
		}

		$white_list = $this->table->get_columns();

		foreach ( $this->args['order'] as $column => $direction ) {

			$direction = strtoupper( $direction );

			if ( ! in_array( $direction, array( Order::ASC, Order::DESC ) ) ) {
				throw new \InvalidArgumentException( "Invalid order direction $direction for column $column." );
			}

			$column = $this->translate_order_by_to_column_name( $column );

			if ( ! isset( $white_list[ $column ] ) ) {
				throw new \InvalidArgumentException( "Invalid order column $column." );
			}

			$column = "{$alias}.$column";

			if ( ! isset( $order ) ) {
				$order = new Order( $column, $direction );
			} else {
				$order->then( $column, $direction );
			}
		}

		if ( isset( $order ) ) {
			return $order;
		} else {
			return new Order( "{$alias}.{$this->table->get_primary_key()}", Order::ASC );
		}
	}
protected function parse_order ( $ alias = 'q' ) { if ( ! is_array ( $ this -> args [ 'order' ] ) && $ this -> args [ 'order' ] === 'rand' ) { return new Order ( Order :: RAND ) ; } elseif ( ! is_array ( $ this -> args [ 'order' ] ) ) { throw new \ InvalidArgumentException ( "Order must either be 'rand' or an array of columns to directions." ) ; } $ white_list = $ this -> table -> get_columns ( ) ; foreach ( $ this -> args [ 'order' ] as $ column => $ direction ) { $ direction = strtoupper ( $ direction ) ; if ( ! in_array ( $ direction , array ( Order :: ASC , Order :: DESC ) ) ) { throw new \ InvalidArgumentException ( "Invalid order direction $direction for column $column." ) ; } $ column = $ this -> translate_order_by_to_column_name ( $ column ) ; if ( ! isset ( $ white_list [ $ column ] ) ) { throw new \ InvalidArgumentException ( "Invalid order column $column." ) ; } $ column = "{$alias}.$column" ; if ( ! isset ( $ order ) ) { $ order = new Order ( $ column , $ direction ) ; } else { $ order -> then ( $ column , $ direction ) ; } } if ( isset ( $ order ) ) { return $ order ; } else { return new Order ( "{$alias}.{$this->table->get_primary_key()}" , Order :: ASC ) ; } }
Parse the orderby query. There is always a default or.

@since 1.0

@param string $alias

@return Order
Parse the orderby query . There is always a default or .