简体   繁体   中英

PHP/MySQL - specific pages for specific users

In my current project in PHP and MySQL, I have a database of user and a database of projects. I want to be able to assign projects to users so that they only have access to those that they have joined (by whatever means). Is there a more efficient way of doing this other than having some sort of array within a field of a user?

Create a table with two foreign keys: one pointing to the primary key of the user table and the other pointing to the primary key of the project table. This is the standard way of implementing so called m:n-relations (a user can have multiple projects and a project consists of multiple users) in relational databases. Read up on database normalization for reasons why.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM