You need to create your own function which will translate sha1
function.
Your app/config/config.yml
file:
doctrine:
orm:
dql:
string_functions:
sha1: YourBundle\DQL\Sha
Your src/YourBundle/DQL/Sha.php
file:
namespace YourBundle\DQL;
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;
use Doctrine\ORM\Query\Lexer;
class Sha extends FunctionNode
{
public $valueToSha = null;
public function parse(Parser $parser)
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$this->valueToSha = $parser->StringPrimary();
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
}
public function getSql(SqlWalker $sqlWalker)
{
return
"sha1("
. $this->valueToSha->dispatch($sqlWalker)
. ")";
}
}
Check doc for more info