我正在使用 Grocery CRUD (创建全功能 CRUD 的 PHP 库)我有非常基本的用户表。
id | first_name | last_name
其中一些用户是亲戚。所以我想要单独的关系表,看起来像
id | first_users_id | second_user_id | relation_type
我如何将这种关系添加到 Grocery CRUD,以便在我编辑用户个人资料时选择其他用户,这些用户是亲戚,为他们每个人提供关系类型?
最佳答案
无需继续,您应该能够像这样完成它: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');
关于php - 同一张表中项目的 N 到 N 关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47308022/