function uniqueValue()
Checks that a unique value doesn't already exist in the database, e.g. a username or email address.
This is to give a friendlier frontend to DB errors pertaining to UNIQUE constraints.
N.B. this function uses LIKE for case-insensitive matching, so it's even stricter than a UNIQUE constraint. Usagevoid Validity::uniqueValue ( string $val , string $table , string $column [, int $id [, string $error_msg ]] ); Example$valid->check('email', 'Validity::uniqueValue', 'users', 'email', UserAuth::get_id()) Example$valid->check('code', 'Validity::uniqueValue', 'events', 'code') Arguments- string $val
Value to check - string $table
Table to search for an extant matching value - string $column
Column in specified table - int $id = 0
The ID of the record being edited (0 if adding a new record). This prevents an exception being
thrown when the record being edited itself is found. - string $error_msg = ''
Error message to be included in the exception
Exceptions thrown
Return value
|