addForeignKey() public method
Builds a SQL statement for adding a foreign key constraint to an existing table.
The method will properly quote the table and column names.
public void addForeignKey ( $name, $table, $columns, $refTable, $refColumns, $delete = null, $update = null ) | ||
---|---|---|
$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. |
$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. |
$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 |
Please login to continue.