H
H
Habr2019-06-05 23:33:13
Yii
Habr, 2019-06-05 23:33:13

How to retrieve records from the database for a specific user(s)?

Hello everyone, how can I display records for a specific user, for example, in a database, table No. 1 stores data with content, and the second table stores data with IDs of users who have access. Relationship - many to many
Table #1
5cf8268a9ac9c996126286.png
Table #2
5cf826ba172d8087768246.png
Sample code
$model = Instances::find()->with('access')->all();

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
noeer, 2019-06-06
@GA_Roman

What prevents to execute 2 requests?
1) Get the instance_id array from table 2 for a specific user.
2) Make a selection of records from table 1 by already known id

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question