JaredRitchey Posted June 16, 2011 Share Posted June 16, 2011 I need to explain this a little so it makes sense. In my script I add my includes at the top of the file which are most often required_once as opposed to an include. There are situations where the names of the included files and the number varies depending on project. Currently I do something like; require_once('project/florida.php'); require_once('project/sdtv.php'); require_once('project/config.php'); What I would like to do is store those values or multiple values in the database such as (florida.php,sdtv.php,config.php) and then in the script I'd query the field to bring back the include. I tried to use an include all files in a folder where I first stored them in /project/ but it was nasty slow. Is there any reason to believe this is a good way of doing things? Quote Link to comment https://forums.phpfreaks.com/topic/239535-storing-includes-in-a-db/ Share on other sites More sharing options...
dragon_sa Posted June 16, 2011 Share Posted June 16, 2011 you can do it without storing them in a database if you want to include a series of files, lets say you have 1 folder where you keep only the files you want to include or require once on your pages, we will say that is your project directory, so something like this <?php // set directory path $dir="project/"; //get all the php files for require $require=glob("" . $dir . "*.php"); // loop through files and create the includes foreach ($require as $file) { require_once($file); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/239535-storing-includes-in-a-db/#findComment-1230454 Share on other sites More sharing options...
trq Posted June 16, 2011 Share Posted June 16, 2011 Is there any reason to believe this is a good way of doing things? No. Quote Link to comment https://forums.phpfreaks.com/topic/239535-storing-includes-in-a-db/#findComment-1230457 Share on other sites More sharing options...
JaredRitchey Posted June 16, 2011 Author Share Posted June 16, 2011 Thorpe, what would you suggest? I need to be able to change the includes on a per project basis. Quote Link to comment https://forums.phpfreaks.com/topic/239535-storing-includes-in-a-db/#findComment-1230458 Share on other sites More sharing options...
Muddy_Funster Posted June 16, 2011 Share Posted June 16, 2011 What's wrong with making a master include script that calls a selection of the other includes specific to given criteria? Quote Link to comment https://forums.phpfreaks.com/topic/239535-storing-includes-in-a-db/#findComment-1230542 Share on other sites More sharing options...
JaredRitchey Posted June 16, 2011 Author Share Posted June 16, 2011 so the include script would include others based on criteria? Should I store this criteria in the DB? Quote Link to comment https://forums.phpfreaks.com/topic/239535-storing-includes-in-a-db/#findComment-1230546 Share on other sites More sharing options...
seany123 Posted June 16, 2011 Share Posted June 16, 2011 what are you planning to do to set the criteria? what i would do is skip the database and a "master" include with something like... $id = $_POST['id']; if ($id == 1){ //include florida } if ($id == 2){ //include another } Quote Link to comment https://forums.phpfreaks.com/topic/239535-storing-includes-in-a-db/#findComment-1230564 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.