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.
/** * {@inheritdoc} */ public function equals($record) { if ($this->isNewRecord && $record->isNewRecord) { return $record === $this; } return parent::equals($record); }
/** * Проверяет наличие AR $object в массиве $object * если любой из аргументов пуст позвращается false * @param ActiveRecord $object * @param ActiveRecord[] $array * @return bool */ public static function activeRecordInArray(ActiveRecord $object, $array) { if (empty($object) || empty($array)) { return false; } foreach ($array as $element) { if ($object->equals($element)) { return true; } } return false; }