Results 1 to 5 of 5

Thread: Scan a directory or table in database

  1. #1
    Join Date
    Aug 2009
    Posts
    63

    Scan a directory or table in database

    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?

  2. #2
    Join Date
    Apr 2008
    Posts
    2,005

    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

  3. #3
    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 ...

  4. #4
    Join Date
    May 2008
    Posts
    2,297

    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

  5. #5
    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

Similar Threads

  1. How to list all table containing SQlite database
    By Neil'o in forum Software Development
    Replies: 4
    Last Post: 24-02-2010, 11:00 PM
  2. Defining primary key on database table
    By Garlands in forum Software Development
    Replies: 4
    Last Post: 09-02-2010, 09:09 PM
  3. Replies: 3
    Last Post: 07-07-2009, 08:51 PM
  4. Check if database or table exists
    By Xan in forum Software Development
    Replies: 2
    Last Post: 29-05-2009, 04:53 PM
  5. Creating xml File from database table in VB.Net
    By Jateen in forum Software Development
    Replies: 2
    Last Post: 29-12-2008, 06:20 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,575,451.49075 seconds with 17 queries