Couple others suggestions...

You need to VAR your query:

In your cffunction tag right after the cfargument tag, add:

<cfset var qUpdateProduct = ""> 

Also, Lose the " and # characters:

<cfset variables.product_id = arguments.product_id>

(However, you don't really need to set this variable unless you need to
store the product_id for the lifetime of the component's instance.)

mike

-----Original Message-----
From: Rick Faircloth [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, October 22, 2008 9:10 AM
To: cf-talk
Subject: How can this CFC be improved?

Hi, all... still trying to get a handle on using CFC's.

Here's an update method I wrote and I'd like to know what can be changed
to make it better.  Such as, why not use the form scope in the query?
And, why not just use the application scope for the dsn, instead of
converting it to the variables scope?

If components have access to the url, form, session, and application
scopes, etc., why not use them in the component?
What's the benefit of converting them?

<cffunction    name               =    "update_product"
                     displayname    =    "update_product"
                     hint                  =    "Update specified
product"
                     output              =    "false">
                   
        <cfargument name="product_id" type="string" required="yes">
        <cfset variables.product_id = "#arguments.product_id#">
       
        <cfquery name = "qUpdateProduct" datasource="#application.dsn#">
       
                update        products
<snip />

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314219
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to