protected function joinOrdering($orders) { if (count($orders) > 0) { $str = array(); foreach ($orders as $column => $direction) { $str[] = $column . ' ' . $direction; } return 'ORDER BY ' . implode(', ', $str); } }