简体   繁体   English

PHP Bug跟踪器:存储附件

[英]PHP bug tracker: storing attached files

Given a PHP bug tracker project with an SQL DB (MySQL, PostgreSQL, Oracle...), which should be able to store attached files for each bug. 给定一个带有SQL DB(MySQL,PostgreSQL,Oracle ...)的PHP错误跟踪器项目,该项目应该能够存储每个错误的附件文件。

How would you basically store info (file info and the file itself) on DB & disk? 您基本上如何将信息(文件信息和文件本身)存储在数据库和磁盘上?

eg 例如

  • DB: the table bug would have a related table bug_files having a bug_id field, and a filename field containing path to file on disk DB:表错误将有一个相关的表bug_files ,其中包含一个bug_id字段,以及一个文件名字段,其中包含磁盘上文件的路径
  • Disk: storing files in an efficient way (avoiding having too many files in a single directory), eg automatically create directories 1-1000 , 1001-2000 , etc. so we can have /1001-2000/1234/bugfile.jpg or random subdirectories like /z/e/x/q/1000_bugfile.jpg ? 磁盘:以高效的方式存储文件(避免在一个单一的目录有太多的文件),例如自动创建目录1-1000,1001-2000等,所以我们可以有/1001-2000/1234/bugfile.jpg或随机/z/e/x/q/1000_bugfile.jpg之类的子目录?

...or are there a more efficient ways? ...或者有没有更有效的方法?

Thanks. 谢谢。

EDIT 编辑

It also depends on how you want to get to these files, do you use a back-end webpage that fetches all bugs and creates the links for you? 它还取决于您如何获取这些文件,您是否使用获取所有错误并为您创建链接的后端网页? Or do you get an e-mail after a bug occured and do you have to find it manually? 还是在发生错误后收到电子邮件,并且必须手动查找? I don't think this choice mathers a lot. 我认为这种选择没有太大意义。

Files would be listed / uploaded / downloaded through the bug tracking web application (=> HTTP upload / download). 文件将通过错误跟踪Web应用程序列出/上传/下载(=> HTTP上传/下载)。

Nobody except developers / sysadmins would be able to view the automatically generated directory structure (however it would be more convenient to have a "clear" structure). 除了开发人员/系统管理员之外,没有人能够查看自动生成的目录结构(但是,拥有“清晰的”结构会更方便)。

I'd let the file system do its job (file storage). 我会让文件系统完成其工作(文件存储)。 Databases can be used for file storage but it's not (generally) as efficient, eg the file data may be put in the database buffers - this in itself isn't bad, but it may take resources away from other tables, row data and reduce the performance of other queries. 数据库可以用于文件存储,但是(通常)效率不高,例如,文件数据可以放在数据库缓冲区中-这本身还不错,但是它可能会占用其他表,行数据并减少资源其他查询的性能。

Creating directories based on a meaningful combination of date and project names etc. would help reduce the performance loss when having many files in the same directory. 根据日期和项目名称等的有意义的组合创建目录将有助于减少在同一目录中有许多文件时的性能损失。

I'd strongly suggest using recognizeable directory structure, perhaps even date based or something that matches up with (parts) of your bug filename. 我强烈建议使用可识别的目录结构,甚至可能基于日期或与错误文件名的(部分)匹配的内容。 Fe '20110506-bugfile' would be in /2011/05/06/ Perhaps this is a little to matching and only 2011/05/ would be enough. Fe'20110506-bugfile'将在/ 2011/05/06 /中也许有点匹配,仅2011/05 /就足够了。

It also depends on how you want to get to these files, do you use a back-end webpage that fetches all bugs and creates the links for you? 它还取决于您如何获取这些文件,您是否使用获取所有错误并为您创建链接的后端网页? Or do you get an e-mail after a bug occured and do you have to find it manually? 还是在发生错误后收到电子邮件,并且必须手动查找? I don't think this choice mathers a lot.. 我认为这个选择没有太大意义。

A slightly different option is to add the file into your database in the table bug (http://www.php-mysql-tutorial.com/wikis/mysql-tutorials/uploading-files-to-mysql-database.aspx), then you don't have to create a directory structure, BUT, this would not allow you to find the files using an FTP ofcourse. 一个稍微不同的选项是在表错误(http://www.php-mysql-tutorial.com/wikis/mysql-tutorials/uploading-files-to-mysql-database.aspx)中将文件添加到数据库中,那么您不必创建目录结构BUT,这当然不允许您使用FTP来查找文件。

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

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