I am using doctrine2 with symfony2 and I am trying to execute a simple select query:
I want to run:
SELECT * FROM table WHERE status in (1, -1)
This PHP code is:
$queryBuilder = $this->_em->createQueryBuilder(); $queryBuilder ->select('n') ->from('MyBundle:Table', 'n') ->where('n.status IN (1, -1)'); return $queryBuilder->getQuery()->getResult();
Provides the following exception:
[Syntax Error] line 0, col 96: Error: Expected Literal, got '-'
This is an attribute definition inside an object:
/** * @var integer * * @ORM\Column(name="status", type="integer", nullable=true) */ private $status;
If I use only positive numbers in the in argument, it will work. An exception occurs only with negative numbers.
What causes this exception?
source share