Welcome Guest, Not a member yet? Register   Sign In
Store images on database or filesystem?
#10

[eluser]Tom Schlick[/eluser]
[quote author="slowgary" date="1242985447"]Thanks Mushex.

I definitely think the database method would be faster, I've just always tried to avoid unnecessary database tables and in this case I'll still have to read the files from disk, so if I can avoid doing a query beforehand that would be bonus.

What about naming my files with a product id or sku as the prefix, then something sequential, e.g.
Code:
JSE54736_IMAGE_001
JSE54736_IMAGE_002
JSE54736_IMAGE_003
JSE54736_IMAGE_004
Then I can just assume 001 and increment until the file read fails. Of course this would require more code to add or remove images. I'm just thinking out loud here (and typing it). I think having a separate table makes most sense after all. Any other suggestions?[/quote]

or you just have a table in your db called lets say 'product_images' along with another table called 'products' that contains an ID of the product. you then (when you are adding images to the db) add a product_id field to the product_images table so with one query you can say "SELECT * FROM `product_images` WHERE `product_id` = '456'" and bam you have all you need

i dont know why everyone is so afraid of using a db table to store image names. it would be equal speed of scanning an entire folder structure for a certain prefix on a filename. so why not save yourself the hassle and just use a db query that you know will return the right info. unless your db server is housed behind an AOL connection you are good on the speed.


Messages In This Thread
Store images on database or filesystem? - by El Forum - 01-29-2009, 09:21 AM
Store images on database or filesystem? - by El Forum - 01-29-2009, 09:25 AM
Store images on database or filesystem? - by El Forum - 01-29-2009, 10:44 AM
Store images on database or filesystem? - by El Forum - 01-29-2009, 11:45 AM
Store images on database or filesystem? - by El Forum - 01-29-2009, 12:07 PM
Store images on database or filesystem? - by El Forum - 05-21-2009, 09:17 PM
Store images on database or filesystem? - by El Forum - 05-21-2009, 10:21 PM
Store images on database or filesystem? - by El Forum - 05-21-2009, 10:44 PM
Store images on database or filesystem? - by El Forum - 05-22-2009, 07:51 AM
Store images on database or filesystem? - by El Forum - 05-22-2009, 07:56 AM
Store images on database or filesystem? - by El Forum - 05-23-2009, 09:43 PM
Store images on database or filesystem? - by El Forum - 05-24-2009, 03:27 AM
Store images on database or filesystem? - by El Forum - 05-24-2009, 09:27 AM
Store images on database or filesystem? - by El Forum - 05-24-2009, 09:38 AM
Store images on database or filesystem? - by El Forum - 05-24-2009, 11:52 AM



Theme © iAndrew 2016 - Forum software by © MyBB