Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ziaratban committed Jul 16, 2020
1 parent 1e760fe commit 2275449
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/ActiveQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function prepare()
*/
public function all($db = null)
{
return parent::all($db);
return parent::all($db === null ? $this->modelClass::GetDb() : null);
}

/**
Expand All @@ -146,7 +146,7 @@ public function all($db = null)
*/
public function one($db = null)
{
$row = parent::one($db);
$row = parent::one($db === null ? $this->modelClass::GetDb() : null);
if ($row !== false) {
$models = $this->populate([$row]);
return reset($models) ?: null;
Expand All @@ -167,7 +167,7 @@ public function one($db = null)
*/
public function modify($update, $options = [], $db = null)
{
$row = parent::modify($update, $options, $db);
$row = parent::modify($update, $options, $db === null ? $this->modelClass::GetDb() : null);
if ($row !== null) {
$models = $this->populate([$row]);
return reset($models) ?: null;
Expand All @@ -183,12 +183,11 @@ public function modify($update, $options = [], $db = null)
public function getCollection($db = null)
{
/* @var $modelClass ActiveRecord */
$modelClass = $this->modelClass;
if ($db === null) {
$db = $modelClass::getDb();
$db = $this->modelClass::getDb();
}
if ($this->from === null) {
$this->from = $modelClass::collectionName();
$this->from = $this->modelClass::collectionName();
}

return $db->getCollection($this->from);
Expand Down

0 comments on commit 2275449

Please sign in to comment.