简体   繁体   中英

Algorithm to compare files and sub directories in main directory to the database

I need to update the file paths in a directory recursively in the database. Like if I made any changes in the directory, then that has to be updated in the database. What is the best and fastest way to do this using PHP and MySQL.

In your MySQL database you must have these tables:

Directory{
    directory_id: integer;
    directory_name: varchar;
    directory_path: varchar;
    parent_id: fk_to_directoy_id;
}

File{
    file_id: integer;
    file_name: varchar;
    directory_id: fk_to_directory_id;
}

so you can build the hierarchical directory structure and then attach files to its directory.

Then you just need a backend in php to manage these tables. (Look to a framework to make it easy Symfony )

Hope it helped you. Good luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM