Suppress DB updates when values are not changed

This commit is contained in:
Deon George 2015-09-30 21:18:41 +10:00
parent c570b45e49
commit e8c4f00a8d

View File

@ -792,6 +792,20 @@ class Kohana_ORM extends Model implements serializable {
// Object is no longer saved or valid
$this->_saved = $this->_valid = FALSE;
}
// If the replacement value is the same as the original value, we dont need to update.
// @note This assumes that the value returned from the DB is always a string.
if (array_key_exists($column, $this->_original_values) AND (string)$value === $this->_original_values[$column] AND array_key_exists($column, $this->_changed))
{
unset($this->_changed[$column]);
// Reset back our saved status.
if (! count($this->_changed))
{
$this->_saved = $this->_valid = TRUE;
}
}
}
elseif (isset($this->_belongs_to[$column]))
{