i have a dir with a LOT of subdirs, each subdir containing project data outputed by CAD software. i want to keep record of these projects using MySQL but only certain dirs contain valid project data, that can be added to the DB.
The valid project dirs contain a .dat file generated by the cad software ($attFile).
My way of seing what project info has already been added to the DB is to create a "added.dat" file ($dbFile) in the project folder.
The big issue is that the dirstructure is BIG and the project data gets changed pretty often. I need a efective method to .. "cache" the dirstructure data ... so i don't have to read the dirstructure everytime someone reads index.php.
The dirstructure data is stored in the "proj" array ... it is a pretty big object. My idea was to serialise the data into a file (280 kb file ... but i would estimate much more than 5-6 mb txt file when all projects data would be completed) .. that i would remake on request.
This is the function that reads the dirstructure and make's "Project" objects for the valid dir's. proj["db"] - already added dirs proj["vl"] - valid but not added projects.
<?php
function getProjects()
{
$path=globalVars::mainPath;
$dirs=scandir($path);
$i=0;
$j=0;
foreach ($dirs as $currentDir)
{
if ($currentDir!=='.' && $currentDir!=='..')
{
$atFile=$path."/".$currentDir."/".globalVars::attrFile;
$dbFile=$path."/".$currentDir."/".globalVars::dbfile;
if (file_exists($dbFile))
{
$proj["db"][$i]=new Project($currentDir);
$i++;
}
else if (file_exists($atFile))
{
$proj["vl"][$j]=new Project($currentDir);
$j++;
}
}
}
return $proj;
}
?>
i'm pretty beginner with php / coding .. but i started like 1 month ago and i'm learning fast ... any help/comment would be much apreciated