简体   繁体   中英

Yii2 - get data from innerJoinWith

I have two models like this, Pipe -> outGoingPipe

This is the active record :

$model= Pipe::find()
        ->select(["
                    *,
                    sum(piece) as pieces,
                    sum(bundle) as bundles
                "])
        ->innerJoinWith('outgoingPipe',false)
        ->groupBy(['bundle_group'])
        ->where(['in', 'outgoing_pipe_id', $selectedPipe])
        ->orderBy(['container' => SORT_ASC])
        ->all();

Now, if I check by print_r($model) ,

I cannot see the column that came from outgoingPipe.

All the item from Pipe is success selected.

Please advise.

outgoingPipe is available through relation:

$model->outgoingPipe

Notice that by setting second argument in innerJoinWith() to false you lazy-load this relation - it is available only after $model->outgoingPipe has been called.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM