db\BaseActiveRecord unlink()

unlink() public method

Destroys the relationship between two models.

The model with the foreign key of the relationship will be deleted if $delete is true. Otherwise, the foreign key will be set null and the model will be saved without validation.

public void unlink ( $name, $model, $delete = false )
$name string

The case sensitive name of the relationship, e.g. orders for a relation defined via getOrders() method.

$model yii\db\ActiveRecordInterface

The model to be unlinked from the current one. You have to make sure that the model is really related with the current model as this method does not check this.

$delete boolean

Whether to delete the model that contains the foreign key. If false, the model's foreign key will be set null and saved. If true, the model containing the foreign key will be deleted.

throws yii\base\InvalidCallException

if the models cannot be unlinked

doc_Yii
2016-10-30 16:56:56
Comments
Leave a Comment

Please login to continue.