Yii update row fails to update 2 variables at the same time

52 views Asked by At

We need to update 2 parameters in one row from DB: actInTime and the stat.

Based on the current time the status can be 'Working(L)' or 'Working'.

stat is DB is defined as an ENUM with 'Working(L)' and 'Working' as the values.

$shiftData = ShiftDetails::model()->findByPk($shift["shiftID"]);
if(($curentTime - strtotime($shiftData->planInTime)) > 600) {
    $shiftData->stat = 'Working(L)';
}
else {
    $shiftData->stat = 'Working';
}
$shiftData->actInTime = Yii::app()->Date->now();
$shiftData->save();

The issue we face is not repeatable. Some time both actInTime and stat is getting updated, but some times stat is not. actInTime is updating always without any issues

0

There are 0 answers