/**
  * ComparisonOperator ::= "=" | "<" | "<=" | "<>" | ">" | ">=" | "!="
  *
  * @return string
  */
 public function ComparisonOperator()
 {
     switch ($this->lexer->lookahead['value']) {
         case '=':
             $this->match(Lexer::T_EQUALS);
             return '=';
         case '<':
             $this->match(Lexer::T_LOWER_THAN);
             $operator = '<';
             if ($this->lexer->isNextToken(Lexer::T_EQUALS)) {
                 $this->match(Lexer::T_EQUALS);
                 $operator .= '=';
             } else {
                 if ($this->lexer->isNextToken(Lexer::T_GREATER_THAN)) {
                     $this->match(Lexer::T_GREATER_THAN);
                     $operator .= '>';
                 }
             }
             return $operator;
         case '>':
             $this->match(Lexer::T_GREATER_THAN);
             $operator = '>';
             if ($this->lexer->isNextToken(Lexer::T_EQUALS)) {
                 $this->match(Lexer::T_EQUALS);
                 $operator .= '=';
             }
             return $operator;
         case '!':
             $this->match(Lexer::T_NEGATE);
             $this->match(Lexer::T_EQUALS);
             return '<>';
         default:
             $this->syntaxError('=, <, <=, <>, >, >=, !=');
     }
 }
Example #2
0
 /**
  * DeleteClause ::= "DELETE" ["FROM"] AbstractSchemaName ["AS"] AliasIdentificationVariable
  *
  * @return \Doctrine\ORM\Query\AST\DeleteClause
  */
 public function DeleteClause()
 {
     $this->match(Lexer::T_DELETE);
     if ($this->lexer->isNextToken(Lexer::T_FROM)) {
         $this->match(Lexer::T_FROM);
     }
     $token = $this->lexer->lookahead;
     $deleteClause = new AST\DeleteClause($this->AbstractSchemaName());
     if ($this->lexer->isNextToken(Lexer::T_AS)) {
         $this->match(Lexer::T_AS);
     }
     $aliasIdentificationVariable = $this->AliasIdentificationVariable();
     $deleteClause->aliasIdentificationVariable = $aliasIdentificationVariable;
     $class = $this->em->getClassMetadata($deleteClause->abstractSchemaName);
     // Building queryComponent
     $queryComponent = array('metadata' => $class, 'parent' => null, 'relation' => null, 'map' => null, 'nestingLevel' => $this->nestingLevel, 'token' => $token);
     $this->queryComponents[$aliasIdentificationVariable] = $queryComponent;
     return $deleteClause;
 }
Example #3
0
 public function testScannerTokenizesASimpleQueryCorrectly()
 {
     $dql = "SELECT u FROM My\\Namespace\\User u WHERE u.name = 'Jack O''Neil'";
     $lexer = new Lexer($dql);
     $tokens = array(array('value' => 'SELECT', 'type' => Lexer::T_SELECT, 'position' => 0), array('value' => 'u', 'type' => Lexer::T_IDENTIFIER, 'position' => 7), array('value' => 'FROM', 'type' => Lexer::T_FROM, 'position' => 9), array('value' => 'My\\Namespace\\User', 'type' => Lexer::T_IDENTIFIER, 'position' => 14), array('value' => 'u', 'type' => Lexer::T_IDENTIFIER, 'position' => 32), array('value' => 'WHERE', 'type' => Lexer::T_WHERE, 'position' => 34), array('value' => 'u', 'type' => Lexer::T_IDENTIFIER, 'position' => 40), array('value' => '.', 'type' => Lexer::T_DOT, 'position' => 41), array('value' => 'name', 'type' => Lexer::T_IDENTIFIER, 'position' => 42), array('value' => '=', 'type' => Lexer::T_EQUALS, 'position' => 47), array('value' => "Jack O'Neil", 'type' => Lexer::T_STRING, 'position' => 49));
     foreach ($tokens as $expected) {
         $lexer->moveNext();
         $actual = $lexer->lookahead;
         $this->assertEquals($expected['value'], $actual['value']);
         $this->assertEquals($expected['type'], $actual['type']);
         $this->assertEquals($expected['position'], $actual['position']);
     }
     $this->assertFalse($lexer->moveNext());
 }