[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 310
  • Last Modified:

Passing CFC components

I have  a component which I am calling and this has an argument called jetId which is not required.
The idea is that if I pass a jet Id the query excludes it.
The code then does <cfif isDefined("jetID")> Jet id is being found even when I don't pass the argument because there is a variable called jetid contained on the cfm page which is invoking the component.

Is there a way that allows an argument name to be the same as a variable?
0
Lmillard
Asked:
Lmillard
  • 2
1 Solution
 
LmillardAuthor Commented:
sorry, forgot to add code
cfm page invoking the component.


<cfinvoke component="#application.compPath#Jets" method="allJets"
    	returnvariable="allJets">



 the component function


<cfcomponent>
	<cffunction name="allJets" access="public" returntype="query">
		<cfargument name="jetId" type="numeric" required="no">
           
        <cfquery name="allJets" datasource="#application.dataDsn#">
        SELECT 
        jets.*,
        jetCat.catDesc,
        manufacturer.company 
        FROM Jets 
        INNER JOIN jetCat 
        ON jetCat.catID = jets.catID
        INNER JOIN Manufacturer 
        ON jets.manId = manufacturer.manId 
        WHERE status = 1 
        <cfif isDefined("jetID")>
        AND jetID <> #jetID#
        </cfif>
        ORDER BY jets.jetDesc
        </cfquery>
        

		<cfreturn allJets>
	</cffunction>
</cfcomponent>

Open in new window

0
 
PluckaCommented:
variables.jetId is the variable

arguments.jetId is the argument

if you use the scopes it should work.
0
 
LmillardAuthor Commented:
Worked perfectly, thanks very much.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now