Answer the question
In order to leave comments, you need to log in
Yii2 how to make a query with a condition for the existence of connected data?
Good day!
There are two tables, let's say articles and photos.
The query to get data is something like this: $query = Articles::find()->where([...])->with('photos')->all();
Each article from the articles table can have, say, from 0 to 5 photos, that is, in other words, there are either connected records in the photos table for the articles table or they are not.
Can you please tell me how to build a query in such a way as to get only those articles that do not have photos (records in the photos table)?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question