Browse Source

Merge pull request #8179 from thiagotalma/isAttributeChanged

Compare it equals
tags/2.0.4
Qiang Xue 10 years ago
parent
commit
095398f9ce
  1. 1
      framework/CHANGELOG.md
  2. 12
      framework/db/BaseActiveRecord.php

1
framework/CHANGELOG.md

@ -66,6 +66,7 @@ Yii Framework 2 Change Log
- Enh: `yii\widgets\LinkPager::$firstPageLabel` and `yii\widgets\LinkPager::$lastPageLabel` now could be set to true in order to use page number as label (samdark)
- Chg #7924: Migrations in history are now ordered by time applied allowing to roll back in reverse order no matter how these were applied (samdark)
- Chg: Updated dependency to `cebe/markdown` to version `1.1.x` (cebe)
- Chg #8179: Added parameter to define whether the comparison of `yii\db\BaseActiveRecord::isAttributeChanged()` method will be made as identical (thiagotalma)
2.0.3 March 01, 2015

12
framework/db/BaseActiveRecord.php

@ -514,12 +514,18 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
/**
* Returns a value indicating whether the named attribute has been changed.
* @param string $name the name of the attribute
* @return boolean whether the attribute has been changed
* @param bool $identical if the comparison is made as identical
* @return bool whether the attribute has been changed
*/
public function isAttributeChanged($name)
public function isAttributeChanged($name, $identical = true)
{
if (isset($this->_attributes[$name], $this->_oldAttributes[$name])) {
return $this->_attributes[$name] !== $this->_oldAttributes[$name];
if ($identical) {
$changed = $this->_attributes[$name] !== $this->_oldAttributes[$name];
} else {
$changed = $this->_attributes[$name] != $this->_oldAttributes[$name];
}
return $changed;
} else {
return isset($this->_attributes[$name]) || isset($this->_oldAttributes[$name]);
}

Loading…
Cancel
Save