I would like to update multiple records in db using WHERE IN statement with two column check.
Pure MySql raw query looks something like this.. and it works:
UPDATE poll_quota q SET q.count = q.count+1 WHERE q.form_id=14 AND ((q.field_id,q.value) IN (('A',1),('B',1)))
My code:
$this->createQueryBuilder("q")
->update()
->set("q.count","q.count+1")
->where("q.form_id=:form_id")
->andWhere("((q.field_id,q.value) IN (:wherein))")
->setParameter(":form_id",$form_id)
->setParameter(":wherein",$where_in)
->getQuery()
->execute()
;
Output:
[Syntax Error] line 0, col 103: Error: Expected Doctrine\ORM\Query\Lexer::T_CLOSE_PARENTHESIS, got ','
[1/2] QueryException: UPDATE Edge\PollBundle\Entity\Quota q SET q.count = q.count+1 WHERE q.form_id=:form_id AND ((q.field_id,q.value) IN (:wherein)) +
Attemp to do sth like this, also doesn't work:
[...]->andWhere("((q.field_id,q.value) IN ({$where_in}))")
$where_in contains string like this:
"('A',1),('B',1)"