Jump to content

Trips to the database


phppup

Recommended Posts

I know this may seem trivial, but it's like to handle this correctly from a load bearing and a db rules standpoint.

My scenario: a user has several buttons that can access information IF the user is authorized. There is a good chance that the user will click (and come back) several buttons during a session.  Does it make sense to put the entire set $AUTH1, AUTH2, etc. into $_SESSION when running the initial SELECT statement in order to save trips to the database? Our should a separate SELECT be introduced each time?

Analogy: I went to the basement and brought up soda, fruit juice, and bottled water. I only needed water, but there was a good chance I'd need another option later, and wanted to avoid the trip up and down the stairs.

I don't suppose my code gets tired, LOL, but traffic is traffic.

Recommendations?

Link to comment
Share on other sites

OK, so when you went down to the basement your parents had previously said it was ok for you to drink soda. You weren't looking for - and at that point didn't want to drink any - soda but you decided (understandably) that you might want some later, so you brought it up. Cool.

Problem is, between the time you brought the soda up from the basement and the time you decided you actually wanted to drink it, your parents decided you shouldn't have it.

Check permissions every time you do something or expect bad things to happen. If someone logs in with certain rights and abilities, don't expect they'll log out before you change those rights and abilities.

Edited by maxxd
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.