PHP Developers Network

Design question load page parameters from DB
Page 1 of 1

Author:  hybris [ Tue Jul 14, 2015 3:55 am ]
Post subject:  Design question load page parameters from DB


I'm going to do a small webshop (yeah i know there are loads of free ones, Im doing this just to learn php better :) ) and I want to create a code where i store most page info (settings (like page width, height, button names, title and so on)) in a database so I can easily modify the settings if I want to create a new shop later on or maybe create a framework where users can design their own shops..

So I will make the page a class with variablles like
private $keywords;
private $title;
private $buttons; ... and so on.

Each time a user clicks on a button a new page will be drawn with new content.

My question is how will I do this in the best way. I do not want to do a database call (for the page settings anyway) everytime the page loads (only the first time every session).

Should I store the values in session info after initial call to DB and check with isset later on or are there any better way to do this?

Thanks in advance.

Edit: Oh and how secure is the session info? Say I have users with a userlevel that sets permissions.. can I store userlevel in session info or is it better to do a db call for userinfo when trying to access admin functions? /edit

Author:  Christopher [ Tue Jul 14, 2015 1:40 pm ]
Post subject:  Re: Design question load page parameters from DB

Probably the best way to let users can "design their own shops" is to build an editor to customize the stylesheet. You could save the settings in a database somewhere, but it would be best to write a local stylesheet file when they save the settings. If well thought out, the user would be able to highly customize the look of the site -- yet the code and HTML would all stay the same.

Author:  hybris [ Thu Jul 16, 2015 11:58 am ]
Post subject:  Re: Design question load page parameters from DB

Hi and thank You,
yeah but still every time i update the page it will read either the file or db whereever i put the info (I just realized the session is stored as a temp file so it will read from a file no matter what... I guess Im really wondering if its possible to cache parts of the page like menus that will not change..
(the left and top menu will not change so only content that is going to be updated with user actions is the bottom right div)... Is it worth bothering with this at all or should I just make a css file and reload the whole page everytime a user clicks on a button or link?

Also I'm on a webhotel ( so I guess its hard to cache stuff to memory.. maybe I could do it if I had a private server..

Since it will be a webshop I'm extra concerned with the safety... do You guys think the temp session files is secure enough at a place like or should I do my own session functions and store the sessions in a db.. Do You have any experience with that (pro/cons).

Sorry if this is not advanced enough for this forum if so please move it to a more apropriate forum.

Author:  Christopher [ Thu Jul 16, 2015 12:54 pm ]
Post subject:  Re: Design question load page parameters from DB

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group