You need to pass an argument to the function:

<cffunction name="getLinks" access="public" returntype="query">
        
   <cfargument name="category" type="string" required="true" />
        
        <!--- cfquery for CF--->

        <cfquery name="qGetLinks" datasource="#REQUEST.dataSource#">
         SELECT *
         FROM Links
         WHERE category = <cfqueryparam cfsqltype="cf_sql_varchar"
value="#arguments.category#">
         ORDER BY title ASC
      </cfquery>

            <cfreturn qGetLinks>
</cffunction> 

When you call your functions, you then pass it the appropriate category:

<cfinvoke component="Testing" method="getLinks" returnvariable="CFLinks">
        <cfinvokeargument name="category" value="CF">
</cfinvoke>

This way, you have one function that can return both your required
recordsets. Note the use if cfqueryparam, which is best practice. You should
probably var scope your variables within the function too.

Cheers

Will

-----Original Message-----
From: John Barrett [mailto:[email protected]] 
Sent: 21 August 2009 09:14
To: cf-newbie
Subject: Re: cfc query


are you saying change:
<cfquery name="CFLinks" datasource="#REQUEST.dataSource#">
           SELECT *
           FROM Links
           WHERE category = "CF"
           ORDER BY title ASC
       </cfquery>

to

<cfquery name="Links" datasource="#REQUEST.dataSource#">
           SELECT *
           FROM Links
           WHERE category = "CF"
           ORDER BY title ASC
       </cfquery>

and change the WHERE clause? How would this be done?
Basically I am just trying to re produce the query for multiple
categories,and then displaying those results on other page. Is there a
better way to do this?
Thanks,
John




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:4741
Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15

Reply via email to