I've an existing project in Symfony 1.4 and Propel 1.4
For a new requirement, I tried following code:
static public function extendMomentoLock($momentoId,$memberId)
{
$wherec = new Criteria();
$updatec = new Criteria();
$updatec->add(MomentoPeer::LOCKED, 1);
$updatec->addAnd(MomentoPeer::LOCKEDBY, $memberId);
$wherec->add(MomentoPeer::ID, $momentoId, Criteria::EQUAL);
$con = Propel::getConnection(MemberPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
BasePeer::doUpdate($wherec, $updatec, $con);
return "extended";
}
As expected, it generated correct query, as taken from logs
UPDATE momento SET `LOCKED`=1, `LOCKEDBY`=6 WHERE momento.ID='198'
No issue till here.
Problem starts, as I need to run this query every 3 minutes. Rule is, row gets unlocked automatically every 5 minutes, if record is updated 5 minutes earlier. To keep it locked, updated_at
column must be less then 5 minutes so browser sends request to keep record locked.
I was expecting query to update updated_at
column. However, since nothing is updating in query, updated_at
column is not updating.
Is there any way to force propel to execute query, even when no records are updated.
extendMomentoLock
to always update the table, even whenLOCKED
&LOCKEDBY
are the same from previous version, right? – j0kupdated_at
changes which, I know, is a bad solution. Ideal solution is to updateupdated_at
column regardless of other column change or not. – Kapil Sharma$updatec
? – j0k$updatec->addAnd(MomentoPeer::UPDATED_AT, 'NOW()');
? – j0k