active-record icon indicating copy to clipboard operation
active-record copied to clipboard

New methods for ActiveQuery

Open pentiumd2015 opened this issue 6 years ago • 1 comments

public function resetWith()
    {
        $this->with = [];

        if($this->joinWith){
            foreach($this->joinWith AS &$join){
                $join[1] = false;
            }

            unset($join);
        }

        return $this;
    }

Также метод, позволяющий просмотреть весь запрос, который будет выполнен:

public function getRawSql()
    {
        $builder = Yii::$app->db->queryBuilder;

        $query = clone $this;
        $query->resetWith();

        return $query->prepare($builder)->createCommand()->rawSql;
    }

Main point is to clean up eager loading or else there will be the same errors about keys.

Can we add these methods to the new version?

pentiumd2015 avatar Aug 21 '19 07:08 pentiumd2015

@pentiumd2015 translated. Please try using English next time. While Russian is my native language, many people in community can not read it.

As for the feature, it will be considered for Yii 3 if we'll decide to continue developing our own database abstraction layer.

samdark avatar Aug 21 '19 08:08 samdark