naiquevin
naiquevin

Reputation: 7796

The WHERE IN clause using propel in symfony

How can I create the following query using propel ?

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

Upvotes: 3

Views: 7926

Answers (2)

Maerlyn
Maerlyn

Reputation: 34105

$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);

Upvotes: 7

Colin Fine
Colin Fine

Reputation: 3364

Try:

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

(I haven't used IN, so I'm only guessing that the 'value' argument should be an array). Criteria API documentation is at 1.

Upvotes: 1

Related Questions