Skip to content

Instantly share code, notes, and snippets.

@doctrinebot
Created December 13, 2015 18:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doctrinebot/af75b56e37ac54349a45 to your computer and use it in GitHub Desktop.
Save doctrinebot/af75b56e37ac54349a45 to your computer and use it in GitHub Desktop.
Attachments to Doctrine Jira Issue DDC-1091 - https://github.com/doctrine/doctrine2/issues/1686
<?php
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
class bDqlNvl extends FunctionNode {
public $field;
public $fallback;
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) {
return 'NVL(' .
$this->field->dispatch($sqlWalker) . ', ' .
$this->fallback->dispatch($sqlWalker) .
')';
}
public function parse(\Doctrine\ORM\Query\Parser $parser) {
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$this->field = $parser->StringPrimary();
$parser->match(Lexer::T_COMMA);
$this->fallback = $parser->StringPrimary();
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment