Paul...in your code below: - cffunction returntype = "query" - var is "links" - query name is "CFLinks" - returnVariable is "CFLinks"
??? -----Original Message----- From: Paul Kukiel [mailto:[email protected]] Sent: Thursday, August 20, 2009 11:13 PM To: cf-newbie Subject: RE: cfc query Hi John, Take a look at the code you can cut the cfc in half and reuse the same query. Also make sure you var scope method variables and always use <cfqueryparam /> Paul. -----Original Message----- From: John Barrett [mailto:[email protected]] Sent: Thursday, August 20, 2009 9:26 PM To: cf-newbie Subject: cfc query <snip> <cfcomponent> <cffunction name="getLinks " access="public" returntype="query"> <cfargument name="category" type="string"> <cfset var links = "" /> <!--- cfquery for CF---> <cfquery name="CFLinks" datasource="#REQUEST.dataSource#"> SELECT * FROM Links WHERE category = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.category#" /> ORDER BY title ASC </cfquery> <cfreturn links /> </cffunction> </cfcomponent> <!--- myTestPage.cfm---> <cfinvoke component="Testing" method="getLinks" returnvariable="CFlinks "> <cfinvokeargument name="category" value="cf"> </cfinvoke> <cfoutput query="CFlinks"> <a href="#getLinks1.link#">#getLinks1.title#</a> <br /> #description#<p></cfoutput> <p> <cfinvoke component="Testing" method="getLinks" returnvariable="FlashLinks"> <cfinvokeargument name=" category" value="flash"> </cfinvoke> <cfoutput query="Flashlinks"> <a href="#getLinks2.link#">#getLinks2.title#</a> <br /> #description#<p></cfoutput> </snip> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:4734 Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15
