Storing reference to images in database?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bradles
Forum Commoner
Posts: 89
Joined: Wed Jun 30, 2004 10:40 pm

Storing reference to images in database?

Post by bradles »

Hi All,

I have a script for my image gallery that retrieves an array of image names from a folder. Are there any advantages of having these names of images listed in the database?

Am I better to run my script based on what is stored in a database or should I just retrieve the list from the folder and then store the array in a session variable?

Brad.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Personally I like to keep everything stored in a database. Just so I can much more easily manipulate it's data. For instance I only want to get photos inserted from a specific date on. Cannot do that dynamically grabbing your info by checking the folder. This is only one advantage out of many :P

I would say database.
bradles
Forum Commoner
Posts: 89
Joined: Wed Jun 30, 2004 10:40 pm

Post by bradles »

Thanks Phenom,

I looked at phpwebgallery and noticed that in their script they upload the images into a folder but they also run a process which stores all the names in the database. As I'm still wrapping my head around PHP, I didn't know if I should be doing the same thing or not. I think I will try and store them in a database though...it might be good practise.

Brad.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Well it all depends on the scalability you are looking for grabbing the files from the folder. If you want something simple and dont want to involve the database, then why not, there is nothing wrong witth not using a database.
Post Reply