F
F
fman22015-11-24 17:14:00
Yii
fman2, 2015-11-24 17:14:00

How to get not all columns in ActiveRecord relationships in Yii2?

There is a code:

$model = SomeModel::find()->with('relation1')->all();

How to display only some columns from a table that is in relation1? Communication hasMany

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Khomenko, 2015-11-24
@fman2

... = SomeModel::find()->with([
    'relation1' => function (ActiveQuery $activeQuery) {
        $activeQuery->where( ... ); # Любые ваши фантазии
    }
 ])->all();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question