Often it is very helpful to test uniqueness of a record/model in the database, but excluding a few columns for one reason or another. Typical cases might be a record which could be entered by more than one individual where there is a database column for that user, userID, and also a datetime field, createdDate, and a primary key, id, all of which are unique. When testing for duplicates it is only going to be valid if these fields are excluded.
It is possible yii already has this functionality now--if this is the case please notify me and I will remove this extension
// do some work here $model->attributes = $_POST['SomeClass']; // exclude some columns which cause issues, or are always unique $excludeColumns = ['id', 'createdDate', 'userID']; if( $model->getExists($excludeColumns) ) $model->addError('id',"This record is not unique."); else $model->save();