Example #1
0
 /**
  * @return Wax_Db_Query_Select
  */
 public function order($spec, $default = 'ASC')
 {
     if (!is_array($spec)) {
         $spec = array($spec);
     }
     foreach ($spec as $key => $value) {
         if (empty($value)) {
             continue;
         }
         $direction = $default;
         if (preg_match('/(.*)\\s+(ASC|DESC)\\s*$/i', $value, $matches)) {
             $value = trim($matches[1]);
             $direction = $matches[2];
         }
         if (!empty($key)) {
             $value = array($key => $value);
         }
         $this->_order[] = Wax_Db::quoteIdentifierAs($value) . " {$direction}";
     }
     return $this;
 }