Using PHP i want to create a pict开发者_开发问答ure gallery, i need a few suggestion on what would be the best logical solution for this.
a) create a directory for an album and move all the related pictures into the directory and henceforth follow the same way for other albums
b) keep a record or the path using the database(MySQL) and use the relational table (album).
for the method a . is there any way to deal the picture gallery without actually having the need to use the database or XML or whatsoever(database).?
what is your take on this? thank you.
IMO the database route is the one to take, as it will be much more extensible and easier to maintain.
If you decide to add in a rating/description/review/[whatever] at a later date you will have the foundations in place.
you can still create a directory for each album - WordPress adopts this kind of practice (/uploads/2010/10) for instance - (directories for each month)
you could do it without a database, through some means of directory traversal and an imaginative naming scheme - if you wanted to sort or search the images some common naming format would be needed. Plus you are very restricted on meta data.
+1 for database from me. You ~can~ even store the images in the DB. but I prefer to keep them as images and just link to the path.
my $0.02
Personally, I would do a combination of both. You will want to move the pictures into a folder structure that makes sense. Whether or not that is by user or by album or what, that is up to you.
You could potentially use method A and ditch the database by keeping each gallery in a properly named folder and then just open that folder and loop through the contents every time you wanted to display the gallery, but it would make your life much more difficult and it wouldn't make much sense.
By using a database, you have all the benefits of a relational data structure... photos can be linked to galleries and tags can be applied to photos.. you can store permissions by photo or by gallery... you have way more options when going with the database.
精彩评论