Answer the question
In order to leave comments, you need to log in
How to set a table alias in joinWith?
Hello!
In yii1, when requesting with with, the relay table was set by default with an alias - the name of the relay. Can this be done in yii2?
Simple example: there are tables
tbl_post
tbl_user
I write:
User::find()
->joinWith('posts')
->where(['username' => 'any', 'posts.active' => 1])
->all();
Answer the question
In order to leave comments, you need to log in
->joinWith( [
'posts' => function ( ActiveQuery $query ) {
$query->andWhere( ... );
}
] )
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question