Class Constraint
Constraint base class object
Models a database constraint like a unique or primary key.
Namespace: Cake\Database\Schema
Constants
Method Summary
-
__construct() public
Constructor
-
getColumns() public
Gets the constraint columns.
-
getName() public
Gets the constraint name.
-
getType() public
Gets the constraint type.
-
setColumns() public
Sets the constraint columns.
-
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, string $type)
Constructor
Parameters
-
string$name The name of the constraint.
-
array<string>$columns The columns to constraint.
-
string$type The type of constraint, e.g. 'unique', 'primary'.
getColumns() ¶ public
getColumns(): ?array<string>
Gets the constraint columns.
Returns
?array<string>setColumns() ¶ public
setColumns(array<string>|string $columns): $this
Sets the constraint columns.
Parameters
-
array<string>|string$columns Columns
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>