Hi Justin,

Yeah I was alittle confused about <cftransaction> and its uses.
I guess I should wrap it up properly.

Thanks

Regards - Paul


From: Justin <[EMAIL PROTECTED]>
Reply-To: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Subject: Re: [ cf-dev ] Comments!
Date: Tue, 3 Aug 2004 14:37:50 +0100

Looks fine, however you may want to wrap the queries in cftransactions.

Also it would be better to use a variable for your destination in your cfuploads.
Finally you should use <cfqueryparam in your sql for best practise..



Justin

On Aug 3, 2004, at 2:24 PM, Paul Swingewood wrote:

Ok I think I have cracked this next phase for the backend of my shoes application.
I would appreciate any comments on this code. Is this the right way to do it etc .....


Just to let you know this is the modify action page which modifies items .....

Regards - Paul

<cfparam name="PicError" default=0>

<cffile action ="UPLOAD"
filefield ="modifiedsmallpic"
nameconflict = "overwrite"
accept = "image/jpg, image/pjpeg"
destination = "c:/inetpub/wwwroot/store/images/products">

<cfif #file.filewassaved# eq "yes">
<cfset smallpic = '#trim(file.serverfile)#'>
<cffile action ="UPLOAD"
filefield ="modifiedbigpic"
nameconflict = "overwrite"
accept = "image/jpg, image/pjpeg"
destination = "c:/inetpub/wwwroot/store/images/products">
<cfif #file.filewassaved# eq "yes">
<cfset bigpic = '#trim(file.serverfile)#'>
<CFQUERY NAME= "update_query" DATASOURCE= "#application.dsn#">
UPDATE tblitems
SET FKmfgID = #trim(form.modifiedManufacturer)#,
partNum = '#trim(form.modifiedPartNumber)#',
FKcategoryID = #trim(form.modifiedCategory)#,
subcatID = #trim(form.modifiedSubCategory)#,
ItemName = '#trim(form.modifiedItemName)#',
ItemDescription = '#trim(form.modifiedItemDescription)#',
ItemCost = #trim(form.modifiedSellingPrice)#,
teaser = '#trim(form.modifiedTeaser)#',
ItemImage = '#trim(smallpic)#',
ItemBigImage = '#trim(bigpic)#'
WHERE ItemID = #Form.ItemID#
</CFQUERY>
<!--- Now delete the sizes in the itemsizes table where the itemid match
This ensures that any old data is removed where an item is in size 1,2,3 and
the user modifies it to 1,2 (3 must be removed). In this case its easier to remove
all the sizes and then reinsert the new ones (watch those foreign keys)--->
<cfquery name="DeleteSizes" datasource="#application.DSN#">
DELETE FROM tblItemSizes
WHERE FKItemID = #form.itemID#
</cfquery>
<!--- Loop over the sizes inserting the size and the ItemID --->
<cfloop index = "ListElement"
list = "#form.modifiedsize#">
<cfquery name="addtoitemsizes" datasource="#application.DSN#">
INSERT INTO tblItemSizes
(FKItemID,
FKSizeID)
VALUES
('#trim(form.ItemID)#',
'#trim(ListElement)#')
</cfquery>
</cfloop>
<cfelse>
<cfset PicError=1>
</cfif>
<cfelse>
<cfset PicError=2>
</cfif>




--
These lists are syncronised with the CFDeveloper forum at http://forum.cfdeveloper.co.uk/
Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
CFDeveloper Sponsors and contributors:-
*Hosting and support provided by CFMXhosting.co.uk* :: *ActivePDF provided by activepdf.com*
*Forums provided by fusetalk.com* :: *ProWorkFlow provided by proworkflow.com*
*Tutorials provided by helmguru.com* :: *Lists hosted by gradwell.com*


To unsubscribe, e-mail: [EMAIL PROTECTED]




--
These lists are syncronised with the CFDeveloper forum at http://forum.cfdeveloper.co.uk/
Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/


CFDeveloper Sponsors and contributors:-
*Hosting and support provided by CFMXhosting.co.uk* :: *ActivePDF provided by activepdf.com*
*Forums provided by fusetalk.com* :: *ProWorkFlow provided by proworkflow.com*
*Tutorials provided by helmguru.com* :: *Lists hosted by gradwell.com*


To unsubscribe, e-mail: [EMAIL PROTECTED]




-- These lists are syncronised with the CFDeveloper forum at http://forum.cfdeveloper.co.uk/ Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

CFDeveloper Sponsors and contributors:-
*Hosting and support provided by CFMXhosting.co.uk* :: *ActivePDF provided by 
activepdf.com*
     *Forums provided by fusetalk.com* :: *ProWorkFlow provided by proworkflow.com*
          *Tutorials provided by helmguru.com* :: *Lists hosted by gradwell.com*

To unsubscribe, e-mail: [EMAIL PROTECTED]



Reply via email to