Example #1
0
 /**
  * Build SQL ORDER BY clause
  * @param Query $query
  * @return string
  */
 protected function buildOrderByClause(Query $query)
 {
     $orderBy = '';
     foreach ($query->getOrderBy() as $fieldAndDirection) {
         $orderBy .= ",\n\t" . $fieldAndDirection[0] . ' ' . $fieldAndDirection[1];
     }
     if ($orderBy) {
         return "\nORDER BY\n\t" . substr($orderBy, 3);
         // remove first ", "
     } else {
         return '';
     }
 }