同一表中项目的N到N关系

moo*_*der 5 php relational-database grocery-crud

我正在使用Grocery CRUD(创建一个完整功能的CRUD的PHP库),我有非常基本的用户表.

id | first_name | 姓

其中一些用户是亲戚.所以我希望有一个单独的关系表,看起来像

id | first_users_id | second_user_id | relation_type

如何将这种关系添加到Grocery CRUD中,这样当我编辑用户的配置文件时,我会选择其他用户,这些用户是为每个用户提供关系类型的亲戚?

Mic*_*air 0

无需进行太多操作,您应该能够像这样完成它:https ://www.grocerycrud.com/examples/set_a_relation_n_n

您还可以参考此处的文档以使用该函数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');
Run Code Online (Sandbox Code Playgroud)