From c94bd36e89255eb034819b9d1f03042cf4770ece Mon Sep 17 00:00:00 2001 From: drodata Date: Sat, 23 Jan 2016 11:11:02 +0800 Subject: [PATCH] Fixed a wrong method calling. If using `all()`, the value of `$customer` will be an array of `Customer` instances, not a `Customer` instance. Consequently, ``` $customer->unlink('orders', $customer->orders[0]); ``` will throw a PHP Fatal Error: Call to a member function unlink() on array. --- docs/guide/db-active-record.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guide/db-active-record.md b/docs/guide/db-active-record.md index 3977e55051..b3a7f2a374 100644 --- a/docs/guide/db-active-record.md +++ b/docs/guide/db-active-record.md @@ -1221,7 +1221,7 @@ The opposite operation to [[yii\db\ActiveRecord::link()|link()]] is [[yii\db\Act which breaks an existing relationship between two Active Record instances. For example, ```php -$customer = Customer::find()->with('orders')->all(); +$customer = Customer::find()->with('orders')->one(); $customer->unlink('orders', $customer->orders[0]); ```