Class UniqueKey
UniqueKey class
Models a unique key constraint, and provides methods to set driver specific attributes.
Constants
Method Summary
-
__construct() public
Constructor
-
getColumns() public
Gets the constraint columns.
-
getLength() public
Gets the constraint length.
-
getName() public
Gets the constraint name.
-
getType() public
Gets the constraint type.
-
setColumns() public
Sets the constraint columns.
-
setLength() public
Sets the constraint length.
-
setName() public
Sets the constraint name.
-
setType() public
Sets the constraint type.
-
toArray() public
Converts a constraint to an array that is compatible with the constructor.
Method Detail
__construct() ¶ public
__construct(string $name, array<string> $columns, array<string, int>|null $length = null)
Constructor
Parameters
-
string$name The name of the constraint.
-
array<string>$columns The columns to constraint.
-
array<string, int>|null$length optional The length of the columns, if applicable.
getColumns() ¶ public
getColumns(): ?array<string>
Gets the constraint columns.
Returns
?array<string>getLength() ¶ public
getLength(): array<string, int>|null
Gets the constraint length.
Can be an array of column names and lengths under MySQL.
Returns
array<string, int>|nullsetColumns() ¶ public
setColumns(array<string>|string $columns): $this
Sets the constraint columns.
Parameters
-
array<string>|string$columns Columns
Returns
$thissetLength() ¶ public
setLength(array<string, int> $length): $this
Sets the constraint length.
In MySQL unique constraints can have limit clauses to control the number of characters indexed in text and char columns.
Parameters
-
array<string, int>$length array of length values
Returns
$thissetName() ¶ public
setName(string $name): $this
Sets the constraint name.
Parameters
-
string$name Name
Returns
$thissetType() ¶ public
setType(string $type): $this
Sets the constraint type.
Parameters
-
string$type Type
Returns
$thistoArray() ¶ public
toArray(): array<string, mixed>
Converts a constraint to an array that is compatible with the constructor.
Returns
array<string, mixed>