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

 

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.