Answer the question
In order to leave comments, you need to log in
How to make a multi-table select model in Yii2?
Hello! I started to study Yii2, please tell me how to organize a model to return query information from several tables?
The request looks like this:
SELECT tbc.id_client, tbco.birth_date FROM tb_client tbc JOIN tb_contact tbco ON (tbco.id_client=tbc.id_client) where id_reg in (SELECT id_reg FROM tb_reg WHERE id_person = 465)
Answer the question
In order to leave comments, you need to log in
the solution depends on the task:
if you need to get related data for one record, use lazy loading https://github.com/yiisoft/yii2/blob/master/docs/g...
if you need to get related data for many records (for example, for table building) use eager loading https://github.com/yiisoft/yii2/blob/master/docs/g...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question