HumHub Documentation (unofficial)

NoRecordExists extends AbstractDb
in package

Confirms a record does not exist in a table.

Table of Contents

Constants

ERROR_NO_RECORD_FOUND  = 'noRecordFound'
Error constants
ERROR_RECORD_FOUND  = 'recordFound'

Properties

$messageTemplates  : array<string, string>
$messageVariables  : array<string, mixed>
$options  : array<string, mixed>
$abstractOptions  : AbstractOptions|array<string, mixed>
$defaultTranslator  : TranslatorInterface
Default translation object for all validate objects
$defaultTranslatorTextDomain  : string
Default text domain to be used with translator
$exclude  : mixed
$field  : string
$messageLength  : int
Limits the maximum returned length of an error message
$messageTemplates  : array<string, string>
$schema  : string
$select  : Select
Select object to use. can be set, or will be auto-generated
$table  : string
$value  : mixed
The value to be validated

Methods

__construct()  : mixed
Provides basic configuration for use with Laminas\Validator\Db Validators Setting $exclude allows a single record to be excluded from matching.
__get()  : mixed
Magic function returns the value of the requested property, if and only if it is the value or a message variable.
__invoke()  : bool
Invoke as command
getAdapter()  : Adapter
Returns the set adapter
getDefaultTranslator()  : TranslatorInterface|null
Get default translation object for all validate objects
getDefaultTranslatorTextDomain()  : string
Get default translation text domain for all validate objects
getExclude()  : string|array<string|int, mixed>
Returns the set exclude clause
getField()  : string|array<string|int, mixed>
Returns the set field
getMessageLength()  : int
Returns the maximum allowed message length
getMessages()  : array<string, string>
Returns array of validation failure messages
getMessageTemplates()  : array<string, string>
Returns the message templates from the validator
getMessageVariables()  : array<int, string>
Returns an array of the names of variables that are used in constructing validation failure messages
getOption()  : mixed
Returns an option
getOptions()  : array<string, mixed>
Returns all available options
getSchema()  : string
Returns the set schema
getSelect()  : Select
Gets the select object to be used by the validator.
getTable()  : string
Returns the set table
getTranslator()  : TranslatorInterface|null
Return translation object
getTranslatorTextDomain()  : string
Return the translation text domain
hasDefaultTranslator()  : bool
Is there a default translation object set?
hasTranslator()  : bool
Does this validator have its own specific translator?
isTranslatorEnabled()  : bool
Is translation enabled?
isValid()  : bool
Returns true if and only if $value meets the validation requirements
isValueObscured()  : bool
Retrieve flag indicating whether or not value should be obfuscated in messages
setAdapter()  : self
Sets a new database adapter
setDefaultTranslator()  : void
Set default translation object for all validate objects
setDefaultTranslatorTextDomain()  : void
Set default translation text domain for all validate objects
setExclude()  : $this
Sets a new exclude clause
setField()  : $this
Sets a new field
setMessage()  : $this
Sets the validation failure message template for a particular key
setMessageLength()  : void
Sets the maximum allowed message length
setMessages()  : $this
Sets validation failure message templates given as an array, where the array keys are the message keys, and the array values are the message template strings.
setOptions()  : $this
Sets one or multiple options
setSchema()  : $this
Sets a new schema
setSelect()  : $this
Sets the select object to be used by the validator
setTable()  : $this
Sets a new table
setTranslator()  : $this
Set translation object
setTranslatorEnabled()  : $this
Indicate whether or not translation should be enabled
setTranslatorTextDomain()  : $this
Set translation text domain
setValueObscured()  : $this
Set flag indicating whether or not value should be obfuscated in messages
createMessage()  : null|string
Constructs and returns a validation failure message with the given message key and value.
error()  : void
getValue()  : mixed
Returns the validation value
query()  : array<string|int, mixed>
Run query and returns matches, or null if no matches are found.
setValue()  : void
Sets the value to be validated and clears the messages and errors arrays
translateMessage()  : string
Translate a validation message

Constants

ERROR_NO_RECORD_FOUND

Error constants

public mixed ERROR_NO_RECORD_FOUND = 'noRecordFound'

ERROR_RECORD_FOUND

public mixed ERROR_RECORD_FOUND = 'recordFound'

Properties

$abstractOptions

protected AbstractOptions|array<string, mixed> $abstractOptions = [ 'messages' => [], // Array of validation failure messages 'messageTemplates' => [], // Array of validation failure message templates 'messageVariables' => [], // Array of additional variables available for validation failure messages 'translator' => null, // Translation object to used -> Translator\TranslatorInterface 'translatorTextDomain' => null, // Translation text domain 'translatorEnabled' => true, // Is translation enabled? 'valueObscured' => false, ]

$defaultTranslatorTextDomain

Default text domain to be used with translator

protected static string $defaultTranslatorTextDomain = 'default'

$messageLength

Limits the maximum returned length of an error message

protected static int $messageLength = -1

$messageTemplates

protected array<string, string> $messageTemplates = [self::ERROR_NO_RECORD_FOUND => 'No record matching the input was found', self::ERROR_RECORD_FOUND => 'A record matching the input was found']

Message templates

$select

Select object to use. can be set, or will be auto-generated

protected Select $select

Methods

__construct()

Provides basic configuration for use with Laminas\Validator\Db Validators Setting $exclude allows a single record to be excluded from matching.

public __construct([array<string|int, mixed>|Traversable|Select $options = null ]) : mixed

Exclude can either be a String containing a where clause, or an array with field and value keys to define the where clause added to the sql. A database adapter may optionally be supplied to avoid using the registered default adapter.

The following option keys are supported: 'table' => The database table to validate against 'schema' => The schema keys 'field' => The field to check for a match 'exclude' => An optional where clause or field/value pair to exclude from the query 'adapter' => An optional database adapter to use

Parameters
$options : array<string|int, mixed>|Traversable|Select = null

Options to use for this validator

Tags
throws
InvalidArgumentException

__get()

Magic function returns the value of the requested property, if and only if it is the value or a message variable.

public __get(string $property) : mixed
Parameters
$property : string
Tags
throws
InvalidArgumentException

__invoke()

Invoke as command

public __invoke(mixed $value) : bool
Parameters
$value : mixed
Return values
bool

getAdapter()

Returns the set adapter

public getAdapter() : Adapter
Tags
throws
RuntimeException

When no database adapter is defined.

Return values
Adapter

getDefaultTranslatorTextDomain()

Get default translation text domain for all validate objects

public static getDefaultTranslatorTextDomain() : string
Return values
string

getExclude()

Returns the set exclude clause

public getExclude() : string|array<string|int, mixed>
Return values
string|array<string|int, mixed>

getField()

Returns the set field

public getField() : string|array<string|int, mixed>
Return values
string|array<string|int, mixed>

getMessageLength()

Returns the maximum allowed message length

public static getMessageLength() : int
Return values
int

getMessages()

Returns array of validation failure messages

public getMessages() : array<string, string>
Return values
array<string, string>

getMessageTemplates()

Returns the message templates from the validator

public getMessageTemplates() : array<string, string>
Return values
array<string, string>

getMessageVariables()

Returns an array of the names of variables that are used in constructing validation failure messages

public getMessageVariables() : array<int, string>
Return values
array<int, string>

getOption()

Returns an option

public getOption(string $option) : mixed
Parameters
$option : string

Option to be returned

Tags
throws
InvalidArgumentException
Return values
mixed

Returned option

getOptions()

Returns all available options

public getOptions() : array<string, mixed>
Return values
array<string, mixed>

Array with all available options

getSchema()

Returns the set schema

public getSchema() : string
Return values
string

getSelect()

Gets the select object to be used by the validator.

public getSelect() : Select

If no select object was supplied to the constructor, then it will auto-generate one from the given table, schema, field, and adapter options.

Return values
Select

The Select object which will be used

getTable()

Returns the set table

public getTable() : string
Return values
string

getTranslatorTextDomain()

Return the translation text domain

public getTranslatorTextDomain() : string
Return values
string

hasDefaultTranslator()

Is there a default translation object set?

public static hasDefaultTranslator() : bool
Return values
bool

hasTranslator()

Does this validator have its own specific translator?

public hasTranslator() : bool
Return values
bool

isTranslatorEnabled()

Is translation enabled?

public isTranslatorEnabled() : bool
Return values
bool

isValid()

Returns true if and only if $value meets the validation requirements

public isValid(mixed $value) : bool
Parameters
$value : mixed
Return values
bool

isValueObscured()

Retrieve flag indicating whether or not value should be obfuscated in messages

public isValueObscured() : bool
Return values
bool

setAdapter()

Sets a new database adapter

public setAdapter(Adapter $adapter) : self
Parameters
$adapter : Adapter
Return values
self

Provides a fluent interface

setDefaultTranslatorTextDomain()

Set default translation text domain for all validate objects

public static setDefaultTranslatorTextDomain([string $textDomain = 'default' ]) : void
Parameters
$textDomain : string = 'default'

setExclude()

Sets a new exclude clause

public setExclude(string|array<string|int, mixed> $exclude) : $this
Parameters
$exclude : string|array<string|int, mixed>
Return values
$this

Provides a fluent interface

setField()

Sets a new field

public setField(string $field) : $this
Parameters
$field : string
Return values
$this

setMessage()

Sets the validation failure message template for a particular key

public setMessage(string $messageString[, string|null $messageKey = null ]) : $this
Parameters
$messageString : string
$messageKey : string|null = null

OPTIONAL

Tags
throws
InvalidArgumentException
Return values
$this

Provides a fluent interface

setMessageLength()

Sets the maximum allowed message length

public static setMessageLength([int $length = -1 ]) : void
Parameters
$length : int = -1

setMessages()

Sets validation failure message templates given as an array, where the array keys are the message keys, and the array values are the message template strings.

public setMessages(array<string, string> $messages) : $this
Parameters
$messages : array<string, string>
Return values
$this

setOptions()

Sets one or multiple options

public setOptions([array<string, mixed>|Traversable<string, mixed> $options = [] ]) : $this
Parameters
$options : array<string, mixed>|Traversable<string, mixed> = []

Options to set

Tags
throws
InvalidArgumentException

If $options is not an array or Traversable.

Return values
$this

Provides fluid interface

setSchema()

Sets a new schema

public setSchema(string $schema) : $this
Parameters
$schema : string
Return values
$this

Provides a fluent interface

setSelect()

Sets the select object to be used by the validator

public setSelect(Select $select) : $this
Parameters
$select : Select
Return values
$this

Provides a fluent interface

setTable()

Sets a new table

public setTable(string $table) : $this
Parameters
$table : string
Return values
$this

Provides a fluent interface

setTranslatorEnabled()

Indicate whether or not translation should be enabled

public setTranslatorEnabled([bool $enabled = true ]) : $this
Parameters
$enabled : bool = true
Return values
$this

setTranslatorTextDomain()

Set translation text domain

public setTranslatorTextDomain([string $textDomain = 'default' ]) : $this
Parameters
$textDomain : string = 'default'
Return values
$this

setValueObscured()

Set flag indicating whether or not value should be obfuscated in messages

public setValueObscured(bool $flag) : $this
Parameters
$flag : bool
Return values
$this

createMessage()

Constructs and returns a validation failure message with the given message key and value.

protected createMessage(string $messageKey, string|array<string|int, mixed>|object $value) : null|string

Returns null if and only if $messageKey does not correspond to an existing template.

If a translator is available and a translation exists for $messageKey, the translation will be used.

Parameters
$messageKey : string
$value : string|array<string|int, mixed>|object
Return values
null|string

error()

protected error(string|null $messageKey[, null|string|array<string|int, mixed>|object $value = null ]) : void
Parameters
$messageKey : string|null
$value : null|string|array<string|int, mixed>|object = null

OPTIONAL

getValue()

Returns the validation value

protected getValue() : mixed
Return values
mixed

Value to be validated

query()

Run query and returns matches, or null if no matches are found.

protected query(string $value) : array<string|int, mixed>
Parameters
$value : string
Return values
array<string|int, mixed>

when matches are found.

setValue()

Sets the value to be validated and clears the messages and errors arrays

protected setValue(mixed $value) : void
Parameters
$value : mixed

translateMessage()

Translate a validation message

protected translateMessage(string $messageKey, string $message) : string
Parameters
$messageKey : string
$message : string
Return values
string

        
On this page

Search results