Example #1
0
 /**
  * ORDER BY keyword
  *
  * @param  Query  $query
  * @param  string $inputString
  * @return string
  */
 private function orderBy(Query $query, $inputString)
 {
     $orderType = $this->getWord($inputString);
     if (!in_array($orderType, $this->types)) {
         $orderField = $orderType;
         $orderType = Query::TYPE_TEXT;
         $inputString = $this->trimString($inputString, $orderField);
     } else {
         $inputString = $this->trimString($inputString, $orderType);
         $orderField = $this->getWord($inputString);
         $inputString = $this->trimString($inputString, $orderField);
     }
     $orderDirection = $this->getWord($inputString);
     if (in_array($orderDirection, $this->orderDirections)) {
         $inputString = $this->trimString($inputString, $orderDirection);
     } else {
         $orderDirection = Query::ORDER_ASC;
     }
     $query->setOrderBy($orderField, $orderDirection, $orderType);
     return $inputString;
 }