Skip to content
Advertisement

Doctrine select with null

Is there a possibility to execute something like:

$builder = $this->getEntityManager()->createQueryBuilder();
$builder->select(
        'f.id',
        ...
        'NULL AS missing_attribute'
    )
    ->from(..., 'f')
    ...;

And avoid:

DoctrineORMQueryQueryException: ... got 'NULL'

Advertisement

Answer

Workaround from https://github.com/doctrine/orm/issues/1670#issuecomment-591495663: select NULLIF(1,1) AS ... instead of NULL AS ...

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement