symfony - Doctrine2 [Syntax Error] Error: Expected Literal, got '-' -


i using doctrine2 symfony2 , trying perform simple select query:

i want run:

select * table status in (1, -1) 

this php code:

$querybuilder = $this->_em->createquerybuilder();         $querybuilder         ->select('n')         ->from('mybundle:table', 'n')         ->where('n.status in (1, -1)'); return $querybuilder->getquery()->getresult(); 

gives following exception:

[syntax error] line 0, col 96: error: expected literal, got '-' 

this attribute definition within entity:

/**  * @var integer  *  * @orm\column(name="status", type="integer", nullable=true)  */ private $status; 

if use positive numbers within in argument, work. exception happens negative numbers.

what causes exception?

should trick :

$querybuilder = $this->_em->createquerybuilder();         $querybuilder         ->select('n')         ->from('mybundle:table', 'n')         ->where('n.status in (:status)')         ->setparameter('status', array(1, -1)); 

Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -