Parses a DQL query, reports any errors in it, and generates an AST.
Since: 2.0
Author: Guilherme Blanco (guilhermeblanco@hotmail.com)
Author: Jonathan Wage (jonwage@gmail.com)
Author: Roman Borschel (roman@code-factory.org)
Author: Janne Vanhala (jpvanhal@cc.hut.fi)
コード例 #1
0
ファイル: DateFunction.php プロジェクト: mesour/filter
 public function parse(Query\Parser $parser)
 {
     $parser->match(Query\Lexer::T_IDENTIFIER);
     $parser->match(Query\Lexer::T_OPEN_PARENTHESIS);
     $this->arg = $parser->ArithmeticPrimary();
     $parser->match(Query\Lexer::T_CLOSE_PARENTHESIS);
 }
コード例 #2
0
ファイル: Sin.php プロジェクト: guiwoda/DoctrineExtensions
 public function parse(\Doctrine\ORM\Query\Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->arithmeticExpression = $parser->SimpleArithmeticExpression();
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 public function parse(Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->stringPrimary = $parser->StringPrimary();
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
コード例 #4
0
ファイル: IdentityFunction.php プロジェクト: ncking/doctrine2
 /**
  * @override
  */
 public function parse(\Doctrine\ORM\Query\Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->pathExpression = $parser->SingleValuedAssociationPathExpression();
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
コード例 #5
0
ファイル: Soundex.php プロジェクト: truckee/match
 public function parse(\Doctrine\ORM\Query\Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->stringExpression = $parser->StringPrimary();
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
コード例 #6
0
ファイル: Hour.php プロジェクト: digvijaymohite/e-tender
 public function parse(\Doctrine\ORM\Query\Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->date = $parser->ArithmeticPrimary();
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
コード例 #7
0
ファイル: DateFunction.php プロジェクト: hamidudc/Proshut
 public function parse(Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->dateExpression = $parser->ArithmeticPrimary();
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
コード例 #8
0
ファイル: Sign.php プロジェクト: Hikariii/doctrine-extensions
 /**
  * {@inheritdoc}
  */
 public function parse(Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->parameters[self::PARAMETER_KEY] = $parser->SimpleArithmeticExpression();
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
コード例 #9
0
ファイル: Randp.php プロジェクト: iakumai/doctrine-functions
 public function parse(Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->value = $parser->SimpleArithmeticExpression();
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
コード例 #10
0
 /**
  * @override
  */
 public function parse(\Doctrine\ORM\Query\Parser $parser)
 {
     $lexer = $parser->getLexer();
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
コード例 #11
0
 public function parse(Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->expressions[] = $parser->ArithmeticFactor();
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
コード例 #12
0
 /**
  * {@inheritdoc}
  */
 public function parse(Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->pathExpression = $parser->SingleValuedPathExpression();
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
コード例 #13
0
ファイル: DateYear.php プロジェクト: josercl/forum
 public function parse(\Doctrine\ORM\Query\Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     //$this->datePart=$parser->StringPrimary();
     $this->dateField = $parser->StateFieldPathExpression();
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
コード例 #14
0
ファイル: CountIf.php プロジェクト: redelivre/login-cidadao
 public function parse(\Doctrine\ORM\Query\Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     // (2)
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     // (3)
     $this->var1 = $parser->ConditionalExpression();
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
     // (3)
 }
コード例 #15
0
ファイル: Year.php プロジェクト: unpetitlu/store
 public function parse(Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     // (2)
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     // (3)
     $this->dateExpression = $parser->ArithmeticExpression();
     // (4)
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
     // (3)
 }
コード例 #16
0
 public function parse(\Doctrine\ORM\Query\Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     // (2)
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     // (3)
     $this->expression = $parser->ArithmeticPrimary();
     // (4)
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
     // (3)
 }
コード例 #17
0
 /**
  * @inheritdoc
  */
 public function parse(\Doctrine\ORM\Query\Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     // 'DATE'
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     // '('
     $this->date = $parser->ArithmeticPrimary();
     // the argument
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
     // ')'
 }
コード例 #18
0
 /**
  * @override
  */
 public function parse(\Doctrine\ORM\Query\Parser $parser)
 {
     $lexer = $parser->getLexer();
     $parser->match($lexer->lookahead['value']);
     $parser->match('(');
     $this->_stringPrimary = $parser->_StringPrimary();
     $parser->match(',');
     $this->_firstSimpleArithmeticExpression = $parser->_SimpleArithmeticExpression();
     $parser->match(',');
     $this->_secondSimpleArithmeticExpression = $parser->_SimpleArithmeticExpression();
     $parser->match(')');
 }
コード例 #19
0
 /**
  * Feeds given parser with previously set literals
  * 
  * @param Parser $parser
  */
 protected function feedParserWithLiterals(Parser $parser)
 {
     $literalsMappingCount = count($this->literalsMapping);
     $lastLitteral = $literalsMappingCount - 1;
     for ($i = 0; $i < $literalsMappingCount; $i++) {
         $parserMethod = $this->literalsMapping[$i];
         $this->literals[$i] = $parser->{$parserMethod}();
         if ($i < $lastLitteral) {
             $parser->match(Lexer::T_COMMA);
         }
     }
 }
コード例 #20
0
 /**
  * @override
  */
 public function parse(\Doctrine\ORM\Query\Parser $parser)
 {
     $lexer = $parser->getLexer();
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->stringPrimary = $parser->StringPrimary();
     $parser->match(Lexer::T_COMMA);
     $this->firstSimpleArithmeticExpression = $parser->SimpleArithmeticExpression();
     $parser->match(Lexer::T_COMMA);
     $this->secondSimpleArithmeticExpression = $parser->SimpleArithmeticExpression();
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
コード例 #21
0
 /**
  * {@inheritdoc}
  */
 public function parse(Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->pathExpression = $parser->SingleValuedAssociationPathExpression();
     if ($parser->getLexer()->isNextToken(Lexer::T_COMMA)) {
         $parser->match(Lexer::T_COMMA);
         $parser->match(Lexer::T_STRING);
         $this->fieldMapping = $parser->getLexer()->token['value'];
     }
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
コード例 #22
0
 public function parse(\Doctrine\ORM\Query\Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->fieldName = $parser->StringPrimary();
     $parser->match(Lexer::T_COMMA);
     $this->queryString = $parser->StringPrimary();
     if ($parser->getLexer()->lookahead['type'] == Lexer::T_COMMA) {
         $parser->match(Lexer::T_COMMA);
         $this->regconfig = $parser->StringPrimary();
     }
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
コード例 #23
0
 /**
  * {@inheritdoc}
  */
 public function parse(Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->parameters[self::SEPARATOR_KEY] = $parser->StringPrimary();
     $parser->match(Lexer::T_COMMA);
     $this->parameters[self::STRINGS_KEY][] = $parser->StringPrimary();
     while ($parser->getLexer()->isNextToken(Lexer::T_COMMA)) {
         $parser->match(Lexer::T_COMMA);
         $this->parameters[self::STRINGS_KEY][] = $parser->StringPrimary();
     }
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
コード例 #24
0
 /**
  * {@inheritDoc}
  */
 public function feedParserWithLiterals(Parser $parser)
 {
     $lexer = $parser->getLexer();
     $this->literals[] = $parser->{$this->commonLiteralMapping}();
     $aheadType = $lexer->lookahead['type'];
     while (Lexer::T_CLOSE_PARENTHESIS !== $aheadType) {
         if (Lexer::T_COMMA === $aheadType) {
             $parser->match(Lexer::T_COMMA);
             $this->literals[] = $parser->{$this->commonLiteralMapping}();
         }
         $aheadType = $lexer->lookahead['type'];
     }
 }
コード例 #25
0
 public function parse(\Doctrine\ORM\Query\Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $parser->match(Lexer::T_IDENTIFIER);
     $lexer = $parser->getLexer();
     $this->unit = $lexer->token['value'];
     $parser->match(Lexer::T_COMMA);
     $this->firstDatetimeExpression = $parser->ArithmeticPrimary();
     $parser->match(Lexer::T_COMMA);
     $this->secondDatetimeExpression = $parser->ArithmeticPrimary();
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
コード例 #26
0
ファイル: ConcatWs.php プロジェクト: m3uzz/onionfw
 /**
  * {@inheritdoc}
  */
 public function parse(\Doctrine\ORM\Query\Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->parameters['separator'] = $parser->StringPrimary();
     $parser->match(Lexer::T_COMMA);
     $this->parameters['strings'][] = $parser->StringPrimary();
     while ($parser->getLexer()->isNextToken(Lexer::T_COMMA)) {
         $parser->match(Lexer::T_COMMA);
         $this->parameters['strings'][] = $parser->StringPrimary();
     }
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
コード例 #27
0
 public function parse(Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->expressions[] = $parser->ArithmeticFactor();
     $parser->match(Lexer::T_COMMA);
     $this->expressions[] = $parser->ArithmeticFactor();
     $lexer = $parser->getLexer();
     if ($lexer->lookahead['type'] === Lexer::T_COMMA) {
         $parser->match(Lexer::T_COMMA);
         $this->expressions[] = $parser->ArithmeticFactor();
     }
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
コード例 #28
0
ファイル: TrimFunction.php プロジェクト: manish436/zform
 /**
  * @override
  */
 public function parse(\Doctrine\ORM\Query\Parser $parser)
 {
     $lexer = $parser->getLexer();
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     if (strcasecmp('leading', $lexer->lookahead['value']) === 0) {
         $parser->match(Lexer::T_LEADING);
         $this->leading = true;
     } else {
         if (strcasecmp('trailing', $lexer->lookahead['value']) === 0) {
             $parser->match(Lexer::T_TRAILING);
             $this->trailing = true;
         } else {
             if (strcasecmp('both', $lexer->lookahead['value']) === 0) {
                 $parser->match(Lexer::T_BOTH);
                 $this->both = true;
             }
         }
     }
     if ($lexer->isNextToken(Lexer::T_STRING)) {
         $parser->match(Lexer::T_STRING);
         $this->trimChar = $lexer->token['value'];
     }
     if ($this->leading || $this->trailing || $this->both || $this->trimChar) {
         $parser->match(Lexer::T_FROM);
     }
     $this->stringPrimary = $parser->StringPrimary();
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
コード例 #29
0
 /**
  * Calculates total count of query records
  *
  * @param Query $query
  * @param \Doctrine\Common\Collections\ArrayCollection|array|null $parameters Query parameters.
  * @return integer
  */
 public function getCount(Query $query, $parameters = null)
 {
     if (!empty($parameters)) {
         $query = clone $query;
         $query->setParameters($parameters);
     }
     $parser = new Parser($query);
     $parserResult = $parser->parse();
     $parameterMappings = $parserResult->getParameterMappings();
     list($sqlParameters, $parameterTypes) = $this->processParameterMappings($query, $parameterMappings);
     $statement = $query->getEntityManager()->getConnection()->executeQuery('SELECT COUNT(*) FROM (' . $query->getSQL() . ') AS e', $sqlParameters, $parameterTypes);
     $result = $statement->fetchColumn();
     return $result ? (int) $result : 0;
 }
コード例 #30
0
ファイル: MysqlDateSub.php プロジェクト: fxlacroix/component
 /**
  * Parse the DQL
  *
  * @param \Doctrine\ORM\Query\Parser $parser
  */
 public function parse(Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->firstDateExpression = $parser->ArithmeticPrimary();
     $parser->match(Lexer::T_COMMA);
     $parser->match(Lexer::T_IDENTIFIER);
     $this->intervalExpression = $parser->ArithmeticPrimary();
     $parser->match(Lexer::T_IDENTIFIER);
     /* @var $lexer Lexer */
     $lexer = $parser->getLexer();
     $this->unit = $lexer->token['value'];
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }