db\Command addForeignKey()

addForeignKey() public method

Creates a SQL command for adding a foreign key constraint to an existing table.

The method will properly quote the table and column names.

public $this 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.

$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.

$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 $this

The command object itself

doc_Yii
2016-10-30 16:57:20
Comments
Leave a Comment

Please login to continue.