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.
This commit is contained in:
drodata
2016-01-23 11:11:02 +08:00
parent c79ebf49f4
commit c94bd36e89

View File

@@ -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, which breaks an existing relationship between two Active Record instances. For example,
```php ```php
$customer = Customer::find()->with('orders')->all(); $customer = Customer::find()->with('orders')->one();
$customer->unlink('orders', $customer->orders[0]); $customer->unlink('orders', $customer->orders[0]);
``` ```