简体   繁体   English

将主目录中的文件和子目录与数据库进行比较的算法

[英]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. 使用PHP和MySQL的最佳和最快方法是什么?

In your MySQL database you must have these tables: 在您的MySQL数据库中,您必须具有以下表:

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. 然后,您只需要php中的后端即可管理这些表。 (Look to a framework to make it easy Symfony ) (寻找一个使Symfony变得容易的框架)

Hope it helped you. 希望对您有所帮助。 Good luck. 祝好运。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将所有文件从子目录移动到主目录中 - Move all files from sub directories into main directory 是否可以使用glob从根目录和子目录中获取文件? - is it possible to get files from a root directory and sub directories with glob? PHP:将目录及子目录下的文件列表成一个XML文件 - PHP : list files in directory and sub-directories into an XML file 递归获取目录中的所有文件,并按扩展名获取子目录 - Recursivly get all files in a directory, and sub directories by extension 从当前目录和子目录中检索所有文件 - Retrieve all files from current directory and sub-directories PHP - 仅显示目录和子目录中的PHP文件 - PHP - displaying just PHP files from a directory and sub directories 将目录中的所有子目录和文件递归添加到数组中 - Recursively adding all sub directories and files from a directory into an array PHP删除目录和任何子目录中所有空文件 - PHP Delete all files that are empty in a Directory and any sub directories PHP递归函数:获取目录及其子目录中的所有文件和目录 - PHP Recursive function: Get all files and directories within a directory and its sub-directories 如何在子目录中使用子目录名称的前缀重命名所有文件,然后将文件移动到新目录? - How can I rename all files in sub-directories with prefix of sub-directory name and then move files to new directory?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM