![]() |
|
Snippets |
|
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
Compared to the update query using Propel snippet which pass 2 criterias to the BasePeer:doUpdate method, here we pass only one criteria to the MyObjectPeer::doUpdate method. This method remove the index ID of the "set" criteria and use it for the "select" criteria.
Comments on this snippet
Works only if your Where clause is only on the object primary key, so this solution can only be used in a limited number of cases.