class DuplicateEntryException extends DatabaseException (View source)

Exception for errors related to duplicate entries (e.g. violating a unique index)

Properties

protected string $sql

The SQL that generated this error

from  DatabaseException
protected array $parameters

The parameters given for this query, if any

from  DatabaseException

Methods

public
string
getSQL()

Returns the SQL that generated this error

public
array
getParameters()

The parameters given for this query, if any

public
__construct(string $message = '', string|null $keyName = null, string|null $duplicatedValue = null, string $sql = null, array $parameters = [])

Constructs the database exception

public
string|null
getKeyName()

Get the name of the key which the error is for (e.g. index name)

public
string|null
getDuplicatedValue()

Get the value which was duplicated (e.g. combined value of multiple columns in index)

Details

string getSQL()

Returns the SQL that generated this error

Return Value

string

array getParameters()

The parameters given for this query, if any

Return Value

array

__construct(string $message = '', string|null $keyName = null, string|null $duplicatedValue = null, string $sql = null, array $parameters = [])

Constructs the database exception

Parameters

string $message

The Exception message to throw.

string|null $keyName

The name of the key which the error is for (e.g. index name)

string|null $duplicatedValue

The value which was duplicated (e.g. combined value of multiple columns in index)

string $sql

The SQL executed for this query

array $parameters

The parameters given for this query, if any

string|null getKeyName()

Get the name of the key which the error is for (e.g. index name)

Return Value

string|null

string|null getDuplicatedValue()

Get the value which was duplicated (e.g. combined value of multiple columns in index)

Return Value

string|null