mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-16 07:11:19 +08:00
Replaces commit dfcf037c7. The prvious idea was wrong and broke some tests
This commit is contained in:
@ -772,11 +772,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface
|
|||||||
*/
|
*/
|
||||||
public function viaTable($tableName, $link, callable $callable = null)
|
public function viaTable($tableName, $link, callable $callable = null)
|
||||||
{
|
{
|
||||||
if ($this->primaryModel === null) {
|
$modelClass = $this->primaryModel ? get_class($this->primaryModel) : $this->modelClass;
|
||||||
throw new InvalidConfigException('The "primaryModel" property is not set. The query must be a relation to use junction tables. You probably need to call hasOne() or hasMany() method first.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$modelClass = get_class($this->primaryModel);
|
|
||||||
$relation = new self($modelClass, [
|
$relation = new self($modelClass, [
|
||||||
'from' => [$tableName],
|
'from' => [$tableName],
|
||||||
'link' => $link,
|
'link' => $link,
|
||||||
|
Reference in New Issue
Block a user