public addForeignKey ( string $name, string $table, string | array $columns, string $refTable, string | array $refColumns, string $delete = null, string $update = null ) : string |
$name |
string |
the name of the foreign key constraint. |
$table |
string |
the table that the foreign key constraint will be added to. |
$columns |
string | array |
the name of the column to that the constraint will be added on.
If there are multiple columns, separate them with commas or use an array to represent them. |
$refTable |
string |
the table that the foreign key references to. |
$refColumns |
string | array |
the name of the column that the foreign key references to.
If there are multiple columns, separate them with commas or use an array to represent them. |
$delete |
string |
the ON DELETE option. Most DBMS support these options: RESTRICT, CASCADE, NO ACTION, SET DEFAULT, SET NULL |
$update |
string |
the ON UPDATE option. Most DBMS support these options: RESTRICT, CASCADE, NO ACTION, SET DEFAULT, SET NULL |
return |
string |
the SQL statement for adding a foreign key constraint to an existing table. |