This validator is often used to verify that a foreign key contains a value
that can be found in the foreign table.

When using the message property to define a custom error message, the message
may contain additional placeholders that will be replaced with the actual content. In addition
to the "{attribute}" placeholder, recognized by all validators (see CValidator),
CExistValidator allows for the following placeholders to be specified:

See Also

whether the comparison is case sensitive. Defaults to true.
Note, by setting it to false, you are assuming the attribute type is string.

className
property

public string $className;

the ActiveRecord class name that should be used to
look for the attribute value being validated. Defaults to null,
meaning using the ActiveRecord class of the attribute being validated.
You may use path alias to reference a class name here.

See Also

additional query criteria. Either an array or CDbCriteria.
This will be combined with the condition that checks if the attribute
value exists in the corresponding table column.
This array will be used to instantiate a CDbCriteria object.

$className=$this->className===null?get_class($object):Yii::import($this->className);$attributeName=$this->attributeName===null?$attribute:$this->attributeName;$finder=$this->getModel($className);$table=$finder->getTableSchema(); if(($column=$table->getColumn($attributeName))===null) throw new CException(Yii::t('yii','Table "{table}" does not have a column named "{column}".', array('{column}'=>$attributeName,'{table}'=>$table->name)));