protected function buildOrderBy()
    {
        if (count($this->orderBy) === 0) {
            return '';
        }

        $orders = [];
        foreach ($this->orderBy as $orderBy) {
            $key = $this->quoteIdentifier($orderBy['tableName']) . '.' . $this->quoteIdentifier($orderBy['key']);
            $orders[] = $key . ' ' . $orderBy['direction'];
        }
        return 'ORDER BY ' . implode(', ', $orders);
    }