Пример #1
0
 /**
  * MySQL supports a special form of UNION:
  * (select ...)
  * union
  * (select ...)
  *
  * This function handles this query syntax. Only one such subquery
  * is supported in each UNION block. (select)(select)union(select) is not legal.
  * The extra queries will be silently ignored.
  */
 protected function processMySQLUnion($queries)
 {
     $unionTypes = array('UNION', 'UNION ALL');
     foreach ($unionTypes as $unionType) {
         if (empty($queries[$unionType])) {
             continue;
         }
         foreach ($queries[$unionType] as $key => $tokenList) {
             foreach ($tokenList as $z => $token) {
                 $token = trim($token);
                 if ($token === "") {
                     continue;
                 }
                 // starts with "(select"
                 if (preg_match("/^\\(\\s*select\\s*/i", $token)) {
                     $processor = new DefaultProcessor();
                     $queries[$unionType][$key] = $processor->process($this->removeParenthesisFromStart($token));
                     break;
                 }
                 $processor = new SQLProcessor();
                 $queries[$unionType][$key] = $processor->process($queries[$unionType][$key]);
                 break;
             }
         }
     }
     // it can be parsed or not
     return $queries;
 }
Пример #2
0
 public function process($sql)
 {
     $inputArray = $this->splitSQLIntoTokens($sql);
     // this is the highest level lexical analysis. This is the part of the
     // code which finds UNION and UNION ALL query parts
     $processor = new UnionProcessor();
     $queries = $processor->process($inputArray);
     // If there was no UNION or UNION ALL in the query, then the query is
     // stored at $queries[0].
     if (!$processor->isUnion($queries)) {
         $processor = new SQLProcessor();
         $queries = $processor->process($queries[0]);
     }
     return $queries;
 }
Пример #3
0
 protected function processSQL($token)
 {
     $processor = new SQLProcessor($this->options);
     return $processor->process($token);
 }
Пример #4
0
 protected function processSQL($tokens)
 {
     $processor = new SQLProcessor();
     return $processor->process($tokens);
 }