开发者

Limiting access to data in a multi-tenant app

I am currently building a job search site on that a company can post and edit their开发者_如何转开发 jobs. The problem is that i don't know how to query/limit a logged in company to edit only the jobs that they added to the site. Can anyone help? Please.


if ($loggedIn === true && $_SESSION['Company'] === true) {
    $_SESSION['CompanyID'] = $query['CompanyID'];
}

...

$CompanyID = $_SESSION['CompanyID'];

SELECT Job, Title, JobID
FROM Jobs
WHERE Company = '$CompanyID'


This is more of a database question.

  1. Do you have a table for companies, is there a unique key in the database for each company?

  2. If so, I presume you have a table for jobs?

So you need to add a column to jobs with the id of the company the job posting belongs too. If you want to be able to lookup by company id, I reccomend going into MySql and creating an index.

Once you've figured that out, you can use a query such as the one suggested by @Jared.


Add a FK on the jobs table with the PK of the company table. That's how you'll know who created them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜