\Cake\ORM\RuleIsUnique

Checks that a list of fields from an entity are unique in the table

Summary

Methods
Properties
Constants
__construct()
__invoke()
No public properties found
No constants found
_alias()
$_fields
$_options
N/A
No private methods found
No private properties found
N/A

Properties

$_fields

$_fields : array

The list of fields to check

Type

array

$_options

$_options : array

The options to use.

Type

array

Methods

__construct()

__construct(array  $fields, array  $options = array()) 

Constructor.

Options

  • allowMultipleNulls Set to false to disallow multiple null values in multi-column unique rules. By default this is true to emulate how SQL UNIQUE keys work.

Parameters

array $fields

The list of fields to check uniqueness for

array $options

The additional options for this rule.

__invoke()

__invoke(\Cake\Datasource\EntityInterface  $entity, array  $options) : boolean

Performs the uniqueness check

Parameters

\Cake\Datasource\EntityInterface $entity

The entity from where to extract the fields where the repository key is required.

array $options

Options passed to the check,

Returns

boolean

_alias()

_alias(string  $alias, array  $conditions, boolean  $multipleNulls) : array

Add a model alias to all the keys in a set of conditions.

Null values will be omitted from the generated conditions, as SQL UNIQUE indexes treat NULL != NULL

Parameters

string $alias

The alias to add.

array $conditions

The conditions to alias.

boolean $multipleNulls

Whether or not to allow multiple nulls.

Returns

array