yii2-activerecord-inheritance icon indicating copy to clipboard operation
yii2-activerecord-inheritance copied to clipboard

An extra query to the database on model.refresh()

Open dabkhazi opened this issue 7 years ago • 0 comments

Hello! First of all thank you for your work!

I found a little issue. Trying explain it :)

If i refresh child model then i see that there are one extra query to parent table. Total 3 queries instead of 2. I explored the source.

public function refresh() {
    $r = parent::refresh();
    return $this->_parent()->refresh() && $r;
}

$r = parent::refresh() do 2 queries: query to child table and extra query to parent, Last query initiate by code:

public static function populateRecord($record, $row) { parent::populateRecord($record, $row);

    _$record->_parent = $record->parent;_
}

Then
$this->_parent()->refresh() && $r do 1 query to parent

Hope you understand my explonation.

dabkhazi avatar Feb 20 '18 10:02 dabkhazi