Created
May 23, 2012 11:40
-
-
Save Basster/2774738 to your computer and use it in GitHub Desktop.
Doctrine MySQL MD5 FunctionNode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace YourCompany\YourCustomer\YourBundle\DQL; | |
use Doctrine\ORM\Query\AST\Functions\FunctionNode; | |
use Doctrine\ORM\Query\Parser; | |
use Doctrine\ORM\Query\SqlWalker; | |
use Doctrine\ORM\Query\Lexer; | |
/** | |
* Adds MySQL MD5 function to DQL Query or QueryBuilder | |
* | |
* MD5Function ::= "MD5" "(" ArithmeticPrimary ")" | |
* | |
*/ | |
class MD5 extends FunctionNode { | |
public $value = null; | |
public function parse(Parser $parser) { | |
$parser->match(Lexer::T_IDENTIFIER); | |
$parser->match(Lexer::T_OPEN_PARENTHESIS); | |
$this->value = $parser->ArithmeticPrimary(); | |
$parser->match(Lexer::T_CLOSE_PARENTHESIS); | |
} | |
public function getSql(SqlWalker $walker) { | |
return "MD5(" . $this->value->dispatch($walker) . ")"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment