Answer the question
In order to leave comments, you need to log in
How to perform count on Yii2 related tables?
There are three tables:
user,
region,
project
It is necessary - to pull out an amount of projects in each region.
the user table has a region_id field, the project table has a user_id field.
That is, display a list of all regions and determine the number of each project in it.
How to make count in this case?
Answer the question
In order to leave comments, you need to log in
1. Create relationships between ActiveRecords of these tables
2. Load data using relations
3. Count the amount of data loaded
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question