RE: Readdir() question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: Luke [mailto:tinmachin3@xxxxxxxxxxxxxx]
> Sent: Friday, September 12, 2008 7:13 AM
> To: Jochem Maas
> Cc: nrixham@xxxxxxxxx; php-general@xxxxxxxxxxxxx
> Subject: Re:  Readdir() question
> 
> Ok,
> 
> one folder on your webserver, and put all of the files that you want
to
> include on your website/system in this folder (also uploading into
this
> folder); just in the root of that folder, so say you wouldn't have
> anymore
> folders under it.
> 
> Make a table called 'Files,' containing:
> 
> ID
> Name
> Type
> true_location
> virtual_location
> 
> (or similar depending on your needs, you might also want a folders
> table,
> perhaps this will increase speed if you are visually displaying the
> entire
> display system.)
> 
> the Name, name of the file
> Type, type of file, I have this in just so i can easily tell what file
> it is
> and what to do without having to execute more scripts.
> true_location, the real location and filename of the file that is
> placed in
> your file
> virtual_location, made up location that forms your filesystem
> 
> The advantages of mapping real files in a virtual location is that you
> and
> the user can interact with the virtual location like it is really
> mapped and
> keep the versatility of MySQL. Since reading several pieces of
> information from MySQL is much faster than reading from files to get
> it.
> 
> For an upload system you would need to write a PHP script on the
upload
> of
> the file to add entries to the table. If you are initially placing
many
> files in there you may want to write a perl/shell/php script to enter
> all of
> the initial file entries for the table for you.

---8<--- snip

It would get a bit ugly when you started having files with the same name
being stored in that physical directory. Obviously, there are ways to
combat this (tack an identifier onto the file name, etc.) but it seems
like it's too much work when there is already a methodology in place
that works--the underlying filesystem.

I guess it would be faster if you cached file attributes (last mod time,
owner, etc.) every now and again on some sort of schedule, and read the
attributes from the table instead of the file itself... but you've still
got to do it in the scheduled job, and your data is stale. Maybe that's
okay, maybe that's not.


Todd Boyd
Web Programmer




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux