Blog Image

Update query in symfony

Suppose you want to execute query like
UPDATE tableName SET column1 = ‘abc’,column2 = ‘xyz’ WHERE column =’1′;
then you can use the below syntax to do so 🙂

—————————————————————————-

$con = Propel::getConnection();

/* Here you have to set the condition for which you need to update */
$c1 = new Criteria();
$c1->add(TableNamePeer::COLUMN_NAME, $conditionForColumn1);

/* Here you have to set the column value */
$c2 = new Criteria();
$c2->add(TableNamePeer::COLUMN_TO_UPDATE, $value);

BasePeer::doUpdate($c1, $c2, $con);



Author: admin

Vinod Ram has been in Software Industry since 2006 and has experience of over 16 years in Software Development & Project Management domain specialised majorly in LAMP stack & Open Source Technology, building enterprise level Web based Application, Large Database driven and huge traffic Websites and Project Management. He loves to write information articles and blog to share his knowledge and experience with the outside world and help people to find solution for their problems.