PHP Class Phalcon\Validation\Validator\Db\Uniqueness
Validator for checking uniqueness of field in database
$uniqueness = new Uniqueness(
[
'table' => 'users',
'column' => 'login',
'message' => 'already taken',
'exclude' => [
'column' => 'id',
'value' => 1 // Some ID to exclude
],
],
$di->get('db');
);
Exclude option is optional.
If second parameter will be null (omitted) than validator will try to get database
connection from default DI instance with \Phalcon\Di::getDefault()->get('db');
Show file
Open project: phalcon/incubator
Public Methods
Method |
Description |
|
__construct ( array $options = [], Phalcon\Db\Adapter\Pdo $db = null ) |
Class constructor. |
|
validate ( Phalcon\Validation $validator, string $attribute ) : boolean |
Executes the uniqueness validation |
|
Method Details
__construct()
public method
public __construct ( array $options = [], Phalcon\Db\Adapter\Pdo $db = null ) |
$options |
array |
|
$db |
Phalcon\Db\Adapter\Pdo |
|
Executes the uniqueness validation