⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

how to show all related data1 to many using $crud->setRelation()



the_coders
  • profile picture
  • Member

Posted 24 July 2017 - 17:05 PM

hi i want to ask how to show all row of data when im want to create a relation to another table the example is below

 

-------------

table a

-------------

id_table_a

name

address

fk_table_b

 

 

-----------

table b

-----------

id_table_b

country

phone_number

 

 

result expextation

 

--------------------------------------------------------------------

Name  |     address   |     country      |      phone_number

---------------------------------------------------------------------

 

 

 

end RESULT is merging table A and table B how to make that happen ? thank you :)

 

 

 

 


arve
  • profile picture
  • Member

Posted 06 September 2017 - 06:32 AM

Hi there, 

 

If you look under:

https://www.grocerycrud.com/enterprise/api-and-function-list/setRelation

 

You can see that you'll need to set:

$crud->setRelation('1', '2', '3') 

1 = The field name at our basic table that we need to related with the foreign key ( in your case: fk_table_b)

2 = The relation table (in your case: table b)

3 = The field that it is recognisable as the title of the related table (in your case: id_table_b)

 

If I understood you correctly. 

 

Hope it helps!