Jump to content

Storing Includes in a DB


JaredRitchey

Recommended Posts

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?

 

Link to comment
https://forums.phpfreaks.com/topic/239535-storing-includes-in-a-db/
Share on other sites

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);
}
?>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.