Suppress DB updates when values are not changed
This commit is contained in:
parent
c50a9c59ec
commit
cb8c3f88f6
@ -789,6 +789,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]))
|
||||
{
|
||||
|
Reference in New Issue
Block a user