I’m quite new in Yii and I would like to know if this problem can be resolved in yii framework. I have three tables (A,B,C), A has the primary key ‘a_id’, B and C have a link to A (for example: b_a_id, c_a_id) that is a foreign key to ‘a_id’, relation A-B is one-to-one, relation A-C is one-to-many.
Is it possible in Yii in a simple way to have:
for relation A - B, an index-page with search bar for every field that displays all the field of A and B
for relation A - C, an index-page with search bar for every field that displays all the field of A and c
the same for A - B - C
I’m not interested in CREATE/UPDATE/DELETE operation, only INDEX with SEARCH
I has been able to show A-B relation using B Controller/Model/View displaying the index page with A fields and B fields. I used a code like that below
<?= GridView::widget([ 'dataProvider' => $dataProviderB, 'filterModel' => $searchModelB, 'columns' => [ //['class' => 'yii\grid\SerialColumn'], 'b_id', 'b_field1', 'b_field2', 'b_a_id.a_field1', //field of B table 'b_a_id.a_field2', 'b_a_id.d_id.field1', //also field of D table liked to B ['class' => 'yii\grid\ActionColumn'], ], ]); ?>
But It’s not available search box on ‘b_a_id.a_field1’, ‘b_a_id.a_field2’ neither obviously on ‘b_a_id.d_id.field1’. I know why. Because using foreign kwy i would like to show more than one field.
Do you have any suggestion for this kind of problem? Should I build a join sql command and display it? And so would the search available? Should I build a view in mysql database and generate model from view?
Please, reply with accuracy because I’m new in Yii
Thanks in advance