Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , ,

Sponsored Links


Scan a directory or table in database

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 03-11-2009
Member
 
Join Date: Aug 2009
Posts: 63
Scan a directory or table in database

Sponsored Links
I have a question: I have a set of files to make available for download. There is no tree, the file name is already clear, etc.

I have two opportunities to retrieve the file list:
- Place all files in a folder, scan the file and exit the list. And it has the advantage of easily by following the addition of new files (you stick in the folder, and it's good).
- Create a table that indexes all the files, then make a call out the basic list. A little more complicated to maintain thereafter, add an entry for each database file, etc.

My question is mainly in terms of speed: do a scan of directory which will actually be heavier than a call basis, or equivalent?

Reply With Quote
  #2  
Old 03-11-2009
kelfro's Avatar
Member
 
Join Date: Apr 2008
Posts: 1,991
Re: Scan a directory or table in database

Yes, but if you stay in reasonable volumes of files, it will do. But by a database you simplify life later if you want to move the files elsewhere, or if you want to put in palc rights management
Reply With Quote
  #3  
Old 03-11-2009
Member
 
Join Date: Aug 2009
Posts: 63
Re: Scan a directory or table in database

For volume, we will type in 10 or 20 large files up. Especially if many visitors that it worries me.

For moving, I just set the path of files in a file PHP constant and change it when it happens, right?

But, it is true that a scan through the directory, rights management is impossible ...
Reply With Quote
  #4  
Old 03-11-2009
Zecho's Avatar
Member
 
Join Date: May 2008
Posts: 2,278
Re: Scan a directory or table in database

Around twenty files, it is strange. But as said above, it is preferable to use a file management via SQL, it will be much easier now, for instance if you want the future to implement a download counter.

And if you really have a lot of visits and the reduction of a select query to your database would make him the greatest good, directs you to a little cache system
Reply With Quote
  #5  
Old 03-11-2009
Member
 
Join Date: Nov 2008
Posts: 1,221
Re: Scan a directory or table in database

If it is to scan your files, you've DirectoryIterator. The DirectoryIterator class provides a simple interface for viewing the contents of filesystem directories.

DirectoryIterator Methods:
  • DirectoryIterator::__construct — Constructs a new directory iterator from a path
  • DirectoryIterator::current — Return the current DirectoryIterator item.
  • DirectoryIterator::getATime — Get last access time of the current DirectoryIterator item
  • DirectoryIterator::getBasename — Get base name of current DirectoryIterator item.
  • DirectoryIterator::getCTime — Get inode change time of the current DirectoryIterator item
  • DirectoryIterator::getFilename — Return file name of current DirectoryIterator item.
  • DirectoryIterator::getGroup — Get group for the current DirectoryIterator item
  • DirectoryIterator::getInode — Get inode for the current DirectoryIterator item
  • DirectoryIterator::getMTime — Get last modification time of current DirectoryIterator item
  • DirectoryIterator::getOwner — Get owner of current DirectoryIterator item
  • DirectoryIterator::getPath — Get path of current Iterator item without filename
  • DirectoryIterator::getPathname — Return path and file name of current DirectoryIterator item
  • DirectoryIterator::getPerms — Get the permissions of current DirectoryIterator item
  • DirectoryIterator::getSize — Get size of current DirectoryIterator item
  • DirectoryIterator::getType — Determine the type of the current DirectoryIterator item
  • DirectoryIterator::isDir — Determine if current DirectoryIterator item is a directory
  • DirectoryIterator::isDot — Determine if current DirectoryIterator item is '.' or '..'
  • DirectoryIterator::isExecutable — Determine if current DirectoryIterator item is executable
  • DirectoryIterator::isFile — Determine if current DirectoryIterator item is a regular file
  • DirectoryIterator::isLink — Determine if current DirectoryIterator item is a symbolic link
  • DirectoryIterator::isReadable — Determine if current DirectoryIterator item can be read
  • DirectoryIterator::isWritable — Determine if current DirectoryIterator item can be written to
  • DirectoryIterator::key — Return the key for the current DirectoryIterator item
  • DirectoryIterator::next — Move forward to next DirectoryIterator item
  • DirectoryIterator::rewind — Rewind the DirectoryIterator back to the start
  • DirectoryIterator::seek — Seek to a DirectoryIterator item
  • DirectoryIterator::__toString — Get file name as a string
  • DirectoryIterator::valid — Check whether current DirectoryIterator position is a valid file
Reply With Quote
Reply

  TechArena Community > Software > Software Development


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Scan a directory or table in database"
Thread Thread Starter Forum Replies Last Post
How to list all table containing SQlite database Neil'o Software Development 4 24-02-2010 10:00 PM
Defining primary key on database table Garlands Software Development 4 09-02-2010 08:09 PM
Actvie Directory Database Corruption >Event ID 467 > Index of table datatable is corrupted PatrModer Active Directory 3 07-07-2009 08:51 PM
Check if database or table exists Xan Software Development 2 29-05-2009 04:53 PM
Creating xml File from database table in VB.Net Jateen Software Development 2 29-12-2008 05:20 PM


All times are GMT +5.5. The time now is 01:46 AM.