Creates unnecessary requests when working with linked tables

Good day comrades.

Faced with an embarrassing problem when you build a query with constraints.

I carry just such a command:


$video = self::find()

            ->from(self::tableName() . ' v')

            ->joinWith(['titles', 'descriptions', 'directors.director', 'genres', 'genres.genre', 'poster', 'movies', 'movies.movie'])

            ->where(['in', 'v.video_id', $list])

            ->orderBy(['v.created_at' => SORT_DESC])

            ->all();

In the debug panel receives adequate working script that pulls all the data I needed.

But the fact is that at the same time he spawn another 40 requests of this kind:


SELECT * FROM `title_language` `tl` WHERE `title_id`=29

P.S. although there select v. *, other fields are pulled out … but if they go to register, anyway the problem is not solved.

What caused this behavior I can not imagine such a request using Yii ‘CDbCriteria’ and ‘with’, not the fruit of a bunch of queries …

I Yii2 not met for a long time, which may not yet know. Please tell me how can I make a request adequately.

Communication I have configured appropriately:


/**

     * Переводы заголовка

     * @return static

     */

    public function getTitles()

    {

        return $this->hasMany(TitleLanguage::className(), ['title_id' => 'video_title_id'])->from(TitleLanguage::tableName() . ' tl');

    }


    /**

     * Переводы описания

     * @return static

     */

    public function getDescriptions()

    {

        return $this->hasMany(DescriptionLanguage::className(), ['description_id' => 'video_description_id'])->from(DescriptionLanguage::tableName() . ' dl');

    }

Once extracted the data, I appeal as follows:

For example, in $ model-> titles