Prado\Data\ActiveRecord\TActiveRecord::equals PHP Method

equals() public method

Compare two records using their primary key values (all column values if table does not defined primary keys). The default uses simple == for comparison of their values. Set $strict=true for identity comparison (===).
public equals ( TActiveRecord $record, $strict = false ) : boolean
$record TActiveRecord
return boolean true if $record equals, false otherwise.
    public function equals(TActiveRecord $record, $strict = false)
    {
        if ($record === null || get_class($this) !== get_class($record)) {
            return false;
        }
        $tableInfo = $this->getRecordTableInfo();
        $pks = $tableInfo->getPrimaryKeys();
        $properties = count($pks) > 0 ? $pks : $tableInfo->getColumns()->getKeys();
        $equals = true;
        foreach ($properties as $prop) {
            if ($strict) {
                $equals = $equals && $this->getColumnValue($prop) === $record->getColumnValue($prop);
            } else {
                $equals = $equals && $this->getColumnValue($prop) == $record->getColumnValue($prop);
            }
            if (!$equals) {
                return false;
            }
        }
        return $equals;
    }