Commit 7a81110f by Carsten Brandt

make ActiveRelation reusable

fixes #1560
parent 089eeaa5
...@@ -63,6 +63,7 @@ class ActiveRelation extends ActiveQuery implements ActiveRelationInterface ...@@ -63,6 +63,7 @@ class ActiveRelation extends ActiveQuery implements ActiveRelationInterface
public function createCommand($db = null) public function createCommand($db = null)
{ {
if ($this->primaryModel !== null) { if ($this->primaryModel !== null) {
$where = $this->where;
// lazy loading // lazy loading
if ($this->via instanceof self) { if ($this->via instanceof self) {
// via pivot table // via pivot table
...@@ -84,6 +85,9 @@ class ActiveRelation extends ActiveQuery implements ActiveRelationInterface ...@@ -84,6 +85,9 @@ class ActiveRelation extends ActiveQuery implements ActiveRelationInterface
} else { } else {
$this->filterByModels([$this->primaryModel]); $this->filterByModels([$this->primaryModel]);
} }
$command = parent::createCommand($db);
$this->where = $where;
return $command;
} }
return parent::createCommand($db); return parent::createCommand($db);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment