Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • Net
  • None
  • PHP
  • system
    • base
    • caching
      • dependencies
    • collections
    • console
    • db
      • ar
      • schema
        • cubrid
        • mssql
        • mysql
        • oci
        • pgsql
        • sqlite
    • i18n
      • gettext
    • logging
    • test
    • utils
    • validators
    • web
      • actions
      • auth
      • filters
      • form
      • helpers
      • renderers
      • services
      • widgets
        • captcha
        • pagers
  • Text
    • Highlighter
  • zii
    • behaviors
    • widgets
      • grid
      • jui

Classes

  • CBooleanValidator
  • CCaptchaValidator
  • CCompareValidator
  • CDateValidator
  • CDefaultValueValidator
  • CEmailValidator
  • CExistValidator
  • CFileValidator
  • CFilterValidator
  • CInlineValidator
  • CNumberValidator
  • CRangeValidator
  • CRegularExpressionValidator
  • CRequiredValidator
  • CSafeValidator
  • CStringValidator
  • CTypeValidator
  • CUniqueValidator
  • CUnsafeValidator
  • CUrlValidator
  • CValidator
  • X2UrlValidator
  • Overview
  • Package
  • Class
  • Tree

Class CUniqueValidator

CUniqueValidator validates that the attribute value is unique in the corresponding database table.

When using the CUniqueValidator::$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), CUniqueValidator allows for the following placeholders to be specified:
  • {value}: replaced with current value of the attribute.
CComponent
Extended by CValidator
Extended by CUniqueValidator
Package: system\validators
Copyright: 2008-2013 Yii Software LLC
License: http://www.yiiframework.com/license/
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 1.0
Located at x2engine/framework/validators/CUniqueValidator.php
Methods summary
protected
# validateAttribute( CModel $object, string $attribute )

Validates the attribute of the object. If there is any error, the error message is added to the object.

Validates the attribute of the object. If there is any error, the error message is added to the object.

Parameters

$object
CModel
$object the object being validated
$attribute
string
$attribute the attribute being validated

Throws

CException
if given table does not have specified column name
protected CActiveRecord
# getModel( string $className )

Given active record class name returns new model instance.

Given active record class name returns new model instance.

Parameters

$className
string
$className active record class name.

Returns

CActiveRecord
active record model instance.

Since

1.1.14
Methods inherited from CValidator
addError(), applyTo(), clientValidateAttribute(), createValidator(), isEmpty(), validate()
Methods inherited from CComponent
__call(), __get(), __isset(), __set(), __unset(), asa(), attachBehavior(), attachBehaviors(), attachEventHandler(), canGetProperty(), canSetProperty(), detachBehavior(), detachBehaviors(), detachEventHandler(), disableBehavior(), disableBehaviors(), enableBehavior(), enableBehaviors(), evaluateExpression(), getEventHandlers(), hasEvent(), hasEventHandler(), hasProperty(), raiseEvent()
Properties summary
public boolean $caseSensitive true
#

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

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

public boolean $allowEmpty true
#

whether the attribute value can be null or empty. Defaults to true, meaning that if the attribute is empty, it is considered valid.

whether the attribute value can be null or empty. Defaults to true, meaning that if the attribute is empty, it is considered valid.

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 class of the object currently being validated. You may use path alias to reference a class name here.

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

See

CUniqueValidator::$attributeName
public string $attributeName
#

the ActiveRecord class attribute name that should be used to look for the attribute value being validated. Defaults to null, meaning using the name of the attribute being validated.

the ActiveRecord class attribute name that should be used to look for the attribute value being validated. Defaults to null, meaning using the name of the attribute being validated.

See

CUniqueValidator::$className
public mixed $criteria array()
#

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.

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.

public string $message
#

the user-defined error message. The placeholders "{attribute}" and "{value}" are recognized, which will be replaced with the actual attribute name and value, respectively.

the user-defined error message. The placeholders "{attribute}" and "{value}" are recognized, which will be replaced with the actual attribute name and value, respectively.

public boolean $skipOnError true
#

whether this validation rule should be skipped if when there is already a validation error for the current attribute. Defaults to true.

whether this validation rule should be skipped if when there is already a validation error for the current attribute. Defaults to true.

Since

1.1.1
Properties inherited from CValidator
$attributes, $builtInValidators, $enableClientValidation, $except, $on, $safe
API documentation generated by ApiGen 2.8.0