PageRenderTime 43ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/library/DoctrineExtensions/Query/Mysql/Md5.php

https://bitbucket.org/maatao/estrutura-b-sica-doctrine
PHP | 56 lines | 22 code | 9 blank | 25 comment | 0 complexity | ff95dc4106fd8e115b251c2095896532 MD5 | raw file
  1. <?php
  2. /*
  3. * DoctrineExtensions Mysql Function Pack
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * If you did not receive a copy of the license and are unable to
  10. * obtain it through the world-wide-web, please send an email
  11. * to kontakt@beberlei.de so I can send you a copy immediately.
  12. */
  13. namespace DoctrineExtensions\Query\Mysql;
  14. use Doctrine\ORM\Query\Lexer;
  15. use Doctrine\ORM\Query\AST\Functions\FunctionNode;
  16. /**
  17. * "MD5" "(" StringPrimary ")"
  18. *
  19. * @category DoctrineExtensions
  20. * @package DoctrineExtensions\Query\Mysql
  21. * @author Andreas Gallien <gallien@seleos.de>
  22. * @license New BSD License
  23. */
  24. class Md5 extends FunctionNode
  25. {
  26. public $stringPrimary;
  27. /**
  28. * @override
  29. */
  30. public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
  31. {
  32. return $sqlWalker->getConnection()->getDatabasePlatform()->getMd5Expression(
  33. $sqlWalker->walkStringPrimary($this->stringPrimary)
  34. );
  35. }
  36. /**
  37. * @override
  38. */
  39. public function parse(\Doctrine\ORM\Query\Parser $parser)
  40. {
  41. $lexer = $parser->getLexer();
  42. $parser->match(Lexer::T_IDENTIFIER);
  43. $parser->match(Lexer::T_OPEN_PARENTHESIS);
  44. $this->stringPrimary = $parser->StringPrimary();
  45. $parser->match(Lexer::T_CLOSE_PARENTHESIS);
  46. }
  47. }