Sunday, March 1, 2009

update according to the primary key using propel

If you want to make an update according to the primary key you just need to use one criteria:

$c = new Criteria();

$c->add(MyObjectPeer::ID,123);

$c->add(MyObjectPeer::NAME,'ola');
$c->add(MyObjectPeer::CITY,'pepito');

MyObjectPeer::doUpdate($c);


and the query is:

UPDATE my_object SET NAME = 'ola',CITY = 'pepito' WHERE my_object.ID=123

0 comments:

Post a Comment