Revision #4 was created by tomvdp on Apr 25, 2014, 1:49:04 PM.
added code that handles null values
Content
[...]
{
if($this->getIsNewRecord())
throw new CDbException(Yii::t('yii','The active record cannot be updated because it is new.'));
if($this->beforeSave())
{
if ($this->detectDirty && $this->_originalHash == $this->calculateHash(true)) {
$this->_isWritten = false;
if ($this->doAfterSaveIfNotDirty)
[...]
/**
* Calculate a hash from the model's attributes. * It excludes attributes in neverMakeDirtyAttributes.
* If $castEmpty=true it will typecast empty string values to null if the matching database field is not a string.
* That is what the Yii framework does when saving, so we need to mimic this here to be able to compare attributes after load and before save.