开发者

Is it good to store dynamically created file's paths in database ?

T开发者_高级运维his is in reference with my earlier question how to organize files created dynamically using php?

I edited the question , with one more aspect, that is storing paths in to the DB. Are there any advantages or disadvantages of doing this?


If you have no other way of finding the file, storing its path in the DB is probably OK.

Still, a couple of notes :

  • I would generally try to see if I could "guess" the file's path from another field -- for instance, from the primary key
    • If it's possible, then, there is no need to store the path in the DB, as it would be some redundant information
  • I would, as much as possible, store some relative path, and not an absolute one.
    • For instance, I would store images/my/image-test.png
    • But not /var/www/images/my/image-test.png
    • That way, moving the directory with the images to another place, or changing of server, using a new one with another path to the DocumentRoot, would still be OK and not break my application.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜