The ratio of N to N in the elements of one table

I work with Grocery CRUD (a PHP library that creates a full functional CRUD), and I have a very simple user table.

id | first_name | last_name

Some of these users are relatives. So I want to have a separate relationship table that looks like

id | first_users_id | second_user_id | relation_type

How can I add this relationship to Grocery CRUD, so when I edit the user profile, I would select other users who are relatives who provide a relationship type for each of them?

+5
source share
1 answer

Without much effort, you should do it like this: https://www.grocerycrud.com/examples/set_a_relation_n_n

You can also link to documents here to use the function https://www.grocerycrud.com/documentation/options_functions/set_relation_n_n

$crud->set_table('user_table'); $crud->set_relation_n_n('relatives', 'user_user_table', 'user_table', 'id', 'id', 'id'); 
0
source

Source: https://habr.com/ru/post/1273399/


All Articles