ok are think we are on diff pages

is your idea to have the image paths stored in a diff table then the rest of 
the product info?

and then ur uploading the images and making a new record for each picture and 
using the productID to pull them together with the record when its shown?
i really dont get how thats more elegant, seems more chances for it to break in 
a few more places

see joe what i was doing was trying to take the looping out so that there is 
only 1 insert and the images are stored in the same table as the rest, so that 
way i can call them as i want without having to pull outta extra tables.

so i maight have some repeating code there but a lot less on the pulling them 
out and/or updating them

i agree it looks cooler but at least 4 me it would be a bigger pita

---------- Original Message ----------------------------------
From: Joe Rinehart <[EMAIL PROTECTED]>
Reply-To: [email protected]
Date:  Wed, 12 Jan 2005 22:00:06 -0500

>(Part 2)
>
>This is a design that would be more of a best practice:
>
>tblProductImages
>-------------------------
>ProductId
>ImageFileName
>
>Then, in your app, have a configuration variable that stores how many
>images are allowed per product.  Let's say that's stored in a variable
>called, well, "maxProductImages".
>
>First, we put our upload and insert into one loop:
>
><cfloop from="1" to="#maxProductImages#" index="i">
> <cffile action="upload" formfield="ImageFileName#i#"...>
> <cfquery...>
>   INSERT INTO tblProductImages (ImageFileName)
>   VALUES ('#cffile.serverfile#')
> </cfquery>
></cfloop>
>
>Much more streamlined, and you can just change maxProductImages
>instead copying/pasting code, introducting typos, etc.
>
>And if you needed all image file names:
>
><cfquery name...>
> SELECT ImageFileName
> FROM tblProductImages
> WHERE productId...
></cfquery>
>
>Don't let your design box you in.  If you're repeating code, there's
>likely to be a better way to do it - try to find it!  Numbered
>fieldnames like "ImageFile1, ImageFile2, ImageFile3" or
>"FavoriteUrl[1-17]" should set off warning klaxons.
>
>Finding better design now also makes the future a lot less painful.
>If your client suddenly wanted to choose a "preferred" image to show
>on the product's main page, you'd have a few different options.
>
>One would be to add a new column to tblProductImages that says which
>other column is preferred.  Yuck - you'd have to do something like two
>queries or a subquery to find out what the preferred column name was.
>
>Another would be to created a tblPreferredProductImages that kept
>track of which column currently kept track of which image is preferred
>for a given product.  Again, selects would get ugly and costly.
>
>The design I suggest, and that I think most developers would prefer,
>make it easy and elegant.  You'd just add a "Preferred" column to
>tblProductImages that was a simple bit flag, and do "SELECT
>ImageFileName FROM tblProductImages WHERE productId = #productId# AND
>Preferred = 1".  It's elegant, it's quick, and doesn't affect our
>existing design or queries in the slightest.  And yes, I skipped using
>cfqueryparam to avoid monkeying up the example.
>
>Have a good night, I've finished my beer now.
>
>-- 
>For Tabs, Trees, and more, use the jComponents:
>http://clearsoftware.net/client/jComponents.cfm
>
>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:190188
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to