Don't forget to use cfqueryparam...
 
John
[EMAIL PROTECTED]
 
 

  _____  

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: Friday, February 02, 2007 12:05 PM
To: [email protected]
Subject: Re: [ACFUG Discuss] CFC and reuse query



Anthony: 

If you have three columns that you want to query on you, can do the
following: 

<cfcomponent> 
  <cffunction name="myFunction" access="public" returntype="string"> 
    <cfargument name="myArgument1" type="string" required="yes"> 
    <cfargument name="myArgument2" type="string" required="yes"> 
    <cfargument name="myArgument3" type="string" required="yes"> 
    <cfset myResult="foo"> 

<cfquery name="qFoo" datasource="datasource"> 

select * 
  from fooTable 
 where 1=1 
   and column1 = '%myArgument1%' 
   and column2 = '%myArgument2%' 
   and column3 = '%myArgument3%' 

</cfquery> 

<!--- or you could do: (this avoids wild cards) ---> 

<cfquery name="qFoo" datasource="datasource"> 

select * 
  from fooTable 
 where 1=1 
 <cfif len(trim(myArgument1))>   and column1 = 'myArgument1'</cfif> 
 <cfif len(trim(myArgument2))>   and column2 = 'myArgument2'</cfif> 
 <cfif len(trim(myArgument3))>   and column3 = 'myArgument3'</cfif> 

</cfquery> 


    <cfreturn myResult> 
  </cffunction> 
</cfcomponent> 

Sincerely,

Brooks Wilson 

Try not to become a man of success but rather to become a man of value. -
Albert Einstein (1879-1955) 




Federal Reserve Bank of Atlanta . 1000 Peachtree Street, N.E. . Atlanta
Georgia 30309-4470
404.498.8178 . fax 404.498.8239 . [EMAIL PROTECTED]







Anthony Mathis <[EMAIL PROTECTED]> 
Sent by: [EMAIL PROTECTED] 


02/02/2007 11:39 AM 


Please respond to
[email protected]



To
[email protected] 

cc

Subject
[ACFUG Discuss] CFC and reuse query

        




I'm looking for a solution to reusing a query in a cfc where the "where
clause needs to change.

example:

  <cfquery name="qry" datasource="#APPLICATION.dsn#">
    select * from table
                 where #field# = #value#
  </cfquery>

How would I pass the info from my cfm to the cfc and continue to run the
same query from the same cfm using different values for #field# and
#value#? Can this be done?

thanks,

Anthony



-------------------------------------------------------------
To unsubscribe from this list, manage your profile @ 
http://www.acfug.org?fa=login.edituserform

For more info, see http://www.acfug.org/mailinglists
Archive @ http://www.mail-archive.com/discussion%40acfug.org/
List hosted by http://www.fusionlink.com
-------------------------------------------------------------









-------------------------------------------------------------
To unsubscribe from this list, manage your profile @ 
http://www.acfug.org?fa=login.edituserform

For more info, see http://www.acfug.org/mailinglists
Archive @ http://www.mail-archive.com/discussion%40acfug.org/
List hosted by http://www.fusionlink.com
-------------------------------------------------------------

Attachment: ATT00379.gif
Description: GIF image

Reply via email to