yii\db\ActiveRecord::equals PHP Method

equals() public method

The comparison is made by comparing the table names and the primary key values of the two active records. If one of the records [[isNewRecord|is new]] they are also considered not equal.
public equals ( ActiveRecord $record ) : boolean
$record ActiveRecord record to compare to
return boolean whether the two active records refer to the same row in the same database table.
    public function equals($record)
    {
        if ($this->isNewRecord || $record->isNewRecord) {
            return false;
        }
        return static::tableName() === $record->tableName() && $this->getPrimaryKey() === $record->getPrimaryKey();
    }

Usage Example

Example #1
0
 /**
  * {@inheritdoc}
  */
 public function equals($record)
 {
     if ($this->isNewRecord && $record->isNewRecord) {
         return $record === $this;
     }
     return parent::equals($record);
 }
All Usage Examples Of yii\db\ActiveRecord::equals