Hi guys, I’m not quite sure why this isn’t working. The code makes logical sense to me, but for some reason the save is throwing an error. Can someone help enlighten me on why this is failing?
What I am trying to do:
Check the "opened" column to see if it is null. If it is, update that column upon initial view and then reload the model.
$model = $this->loadModel();
if($model->opened === NULL)
{
$model->opened = new CDbExpression('NOW()');
if($model->save())
{
$model = $this->loadModel();
}
else
{
//throw new CHttpException(404,'The message could not be updated.');
}
}
Thanks, I will do that, but the reason for the reload is that “opened” would have “NOW()” in it since it’s the expressions being handed over. I will use the refresh though, thanks for info.
And the error is on the $model-save(), I’m not even getting to this part yet… =(
Found the error. I put <?php echo CHtml::errorSummary($model); ?> as the throw statement and found that a field was sending a buggy info. Sorry for the bother guys… =D