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 string 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 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. |
Please login to continue.