@@ -695,28 +695,23 @@ public function parse(Parser $parser, TokensList $list)
695695 $ list ->getNext ();
696696 }
697697
698- // Parsing the SELECT expression with and without the `AS` keyword
699- if ($ token ->type === Token::TYPE_KEYWORD
700- && $ token ->keyword === 'SELECT '
698+ // Parsing the SELECT expression if the view started with it.
699+ if (
700+ $ token ->type === Token::TYPE_KEYWORD
701+ && $ token ->keyword === 'AS '
702+ && $ list ->tokens [$ nextidx ]->type === Token::TYPE_KEYWORD
703+ && $ list ->tokens [$ nextidx ]->value === 'SELECT '
701704 ) {
705+ $ list ->idx = $ nextidx ;
702706 $ this ->select = new SelectStatement ($ parser , $ list );
703- } else {
704- if (
705- $ token ->type === Token::TYPE_KEYWORD
706- && $ token ->keyword === 'AS '
707- && $ list ->tokens [$ nextidx ]->type === Token::TYPE_KEYWORD
708- && $ list ->tokens [$ nextidx ]->value === 'SELECT '
709- ) {
710- $ list ->idx = $ nextidx ;
711- $ this ->select = new SelectStatement ($ parser , $ list );
712- }
713- for (; $ list ->idx < $ list ->count ; ++$ list ->idx ) {
714- $ token = $ list ->tokens [$ list ->idx ];
715- if ($ token ->type === Token::TYPE_DELIMITER ) {
716- break ;
717- }
718- $ this ->body [] = $ token ;
707+ }
708+ // Parsing all other tokens
709+ for (; $ list ->idx < $ list ->count ; ++$ list ->idx ) {
710+ $ token = $ list ->tokens [$ list ->idx ];
711+ if ($ token ->type === Token::TYPE_DELIMITER ) {
712+ break ;
719713 }
714+ $ this ->body [] = $ token ;
720715 }
721716 } elseif ($ this ->options ->has ('TRIGGER ' )) {
722717 // Parsing the time and the event.
0 commit comments