Best Way to Call Data From MySql Table

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
joevis
Forum Newbie
Posts: 5
Joined: Tue Mar 22, 2011 6:50 pm

Best Way to Call Data From MySql Table

Post by joevis »

Hey I'm building a website that accesses a mysql database and grabs data from hundreds of tables to display on various pages.

What would be the best way to call the data I need to display on each page? Would it be better to simply call everything once and dump it into $_SESSION or access the database on each page and grab the info from the results array?
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Best Way to Call Data From MySql Table

Post by social_experiment »

joevis wrote:...grabs data from hundreds of tables to display on various pages.
From this i gather you retrieve the information from other tables, do you store it in a database of your own?
joevis wrote:What would be the best way to call the data I need to display on each page? Would it be better to simply call everything once and dump it into $_SESSION or access the database on each page and grab the info from the results array?
If you store the information in your own database (or if it's stored in another database) it would be quicker (imo) to retrieve it as needed. Storing it in a session variable means you still have to access the database before you store it and then that information is displayed to the user on the requested page (from the variable). Cut out the middle variable so to speak.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
User avatar
kasuals
Forum Commoner
Posts: 28
Joined: Thu Aug 11, 2011 12:59 pm

Re: Best Way to Call Data From MySql Table

Post by kasuals »

If you store the information in your own database (or if it's stored in another database) it would be quicker (imo) to retrieve it as needed.
Quoted for (imo) truth.

I would assume the time it takes (traffic aside) to read in a query from a database even with a large table is less consuming than setting session variables, and retrieving them. The code is probably easier to read too. Sessions are saved on the server side, so it's still being queried.

Then again, assumption is for the ignorant I assume. (harhar)
joevis
Forum Newbie
Posts: 5
Joined: Tue Mar 22, 2011 6:50 pm

Re: Best Way to Call Data From MySql Table

Post by joevis »

Awesome, thanks!
Post Reply