Month: June 2008

update query based on condition

$con = sfContext::getInstance()->getDatabaseConnection(‘propel’);
$c2 = new Criteria();
$c2->add(TblTopPeer::TF_ZIPCODE,$topForecastInfo->getForZipcode());
$c2->add(TblTopPeer::TF_FORCASTDATE,$topForecastInfo->getForForecastdate());

$c3 = new Criteria();
$c3->add(TblTopPeer::TF_FID,$topForecastInfo->getForId());
$c3->add(TblTopPeer::TF_USERID,$topForecastInfo->getForUserid());
$c3->add(TblTopPeer::TF_LATITUDE,$zipInfo->getZipLatitude());
$c3->add(TblTopPeer::TF_LONGITUDE,$zipInfo->getZipLongitude());
BasePeer::doUpdate($c2, $c3, $con);

OR

$con = Propel::getConnection();

// select from...
$c1 = new Criteria();
$c1->add(CommentPeer::POST_ID, $post_id);

// update set
$c2 = new Criteria();
$c2->add(CommentPeer::RATING, 5);

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

How to apply or condition for mysql query in symfony

$cs = new Criteria();
$criterion = $cs->getNewCriterion(HfArticlesPeer::AR_DESCRIPTION,’%’.$searchText.’%’,Criteria::LIKE);
$criterion->addOr($cs->getNewCriterion(HfArticlesPeer::AR_TITLE,’%’.$searchText.’%’,Criteria::LIKE));
$criterion1 = $cs->getNewCriterion(HfArticlesPeer::AR_STATUS,’ARCHIVE’,Criteria::EQUAL);
$criterion1->addOr($cs->getNewCriterion(HfArticlesPeer::AR_STATUS,’PUBLISHED’,Criteria::EQUAL));
$cs->add($criterion1);
$cs->add($criterion);
$cs->add(HfArticlesPeer::AR_CATEGORY ,InsuranceCatId,Criteria::EQUAL);
$searchResInsuranceArticle = HfArticlesPeer::doSelect($cs);