The WHERE IN clause using propel in symfony

naiquevin picture naiquevin · Jul 13, 2010 · Viewed 7.6k times · Source

How can I create the following query using propel ?

UPDATE tablename SET status = 1 WHERE id IN (1,2,3,4)

Answer

Maerlyn picture Maerlyn · Jul 13, 2010
$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);