WHERE IN clause using propel in symfony

How to create the following request using propel?

UPDATE tablename SET status = 1 WHERE id IN (1,2,3,4)
+3
source share
2 answers
$con = Propel::getConnection();

$selectCriteria = new Criteria();
$selectCriteria->add(TablenamePeer::ID, array(1,2,3,4), Criteria::IN);

$updateCriteria = new Criteria();
$updateCriteria->add(TablenamePeer::STATUS, 1);

BasePeer::doUpdate($selectCriteria, $updateCriteria, $con);
+7
source

Try:

$criteria = new Criteria();
$criteria->add(ClassPeer::ID, array(1,2,3,4), Criteria::IN);

(I did not use IN, so I just assume that the argument "value" should be an array). API Criteria documentation is at 1 .

+1
source

Source: https://habr.com/ru/post/1754383/


All Articles