/Doctrine/Extension/Rand.php
PHP | 49 lines | 17 code | 4 blank | 28 comment | 0 complexity | f6797f9b31e347f1c1ace49c103af0b7 MD5 | raw file
- <?php
- /*
- * Copyright 2012 Jan Eichhorn <exeu65@googlemail.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- namespace Exeu\MiscBundle\Doctrine\Extension;
- use Doctrine\ORM\Query\AST\Functions\FunctionNode;
- use Doctrine\ORM\Query\Lexer;
- /**
- * Adds RAND() support to DQL queries
- *
- * @author Jan Eichhorn <exeu65@googlemail.com>
- *
- * RandFunction ::= "RAND" "("")"
- */
- class Rand extends FunctionNode
- {
- /**
- * {@inheritDoc}
- */
- public function parse(\Doctrine\ORM\Query\Parser $parser)
- {
- $parser->match(Lexer::T_IDENTIFIER);
- $parser->match(Lexer::T_OPEN_PARENTHESIS);
- $parser->match(Lexer::T_CLOSE_PARENTHESIS);
- }
- /**
- * {@inheritDoc}
- */
- public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
- {
- return 'RAND()';
- }
- }