protected function buildOrderby() {
		if(!$this->orderBy || !$this->orderBy[0])
			return ['', []];

		$res = [];

		$orderBy = $this->orderBy;
		$orderBySql = $orderBy[0];
		$orderByParameters = $orderBy[1];

		foreach(explode(',', $orderBySql) as $orderbystr) {
			$orderbystr = trim($orderbystr);

			preg_match('/(.*?) (ASC|DESC)?$/i', $orderbystr, $matches);

			if(isset($matches[2])) {
				$direction = $matches[2];
				$column = $matches[1];

				if($this->isIdentifier($column))
					$res[] = $this->replace($column).' '.$direction;
				else
					$res[] = $column.' '.$direction;
			}
			else {
				$column = $orderbystr;

				if($this->isIdentifier($column))
					$res[] = $this->replace($column);
				else
					$res[] = $column;
			}
		}

		$sql = "\n".'ORDER BY '.implode(', ', $res);

		return [$sql, $orderByParameters];
	}
protected function buildOrderby() {
		if(!$this->orderBy || !$this->orderBy[0])
			return ['', []];

		$res = [];

		$orderBy = $this->orderBy;
		$orderBySql = $orderBy[0];
		$orderByParameters = $orderBy[1];

		foreach(explode(',', $orderBySql) as $orderbystr) {
			$orderbystr = trim($orderbystr);

			preg_match('/(.*?) (ASC|DESC)?$/i', $orderbystr, $matches);

			if(isset($matches[2])) {
				$direction = $matches[2];
				$column = $matches[1];

				if($this->isIdentifier($column))
					$res[] = $this->replace($column).' '.$direction;
				else
					$res[] = $column.' '.$direction;
			}
			else {
				$column = $orderbystr;

				if($this->isIdentifier($column))
					$res[] = $this->replace($column);
				else
					$res[] = $column;
			}
		}

		$sql = "\n".'ORDER BY '.implode(', ', $res);

		return [$sql, $orderByParameters];
	}
protected function buildOrderby ( ) { if ( ! $ this -> orderBy || ! $ this -> orderBy [ 0 ] ) return [ '' , [ ] ] ; $ res = [ ] ; $ orderBy = $ this -> orderBy ; $ orderBySql = $ orderBy [ 0 ] ; $ orderByParameters = $ orderBy [ 1 ] ; foreach ( explode ( ',' , $ orderBySql ) as $ orderbystr ) { $ orderbystr = trim ( $ orderbystr ) ; preg_match ( '/(.*?) (ASC|DESC)?$/i' , $ orderbystr , $ matches ) ; if ( isset ( $ matches [ 2 ] ) ) { $ direction = $ matches [ 2 ] ; $ column = $ matches [ 1 ] ; if ( $ this -> isIdentifier ( $ column ) ) $ res [ ] = $ this -> replace ( $ column ) . ' ' . $ direction ; else $ res [ ] = $ column . ' ' . $ direction ; } else { $ column = $ orderbystr ; if ( $ this -> isIdentifier ( $ column ) ) $ res [ ] = $ this -> replace ( $ column ) ; else $ res [ ] = $ column ; } } $ sql = "\n" . 'ORDER BY ' . implode ( ', ' , $ res ) ; return [ $ sql , $ orderByParameters ] ; }
Build ORDER By.
@return array
Build ORDER By .