Skip to main content
Inspiring
November 11, 2008
Question

A Quick CFC Help?

  • November 11, 2008
  • 1 reply
  • 291 views
Hi, I am stuck at one point

I want to know howi can call the one queryvalue into another in a cfc.

like i have one query which counts all the rows and in the next query, i get the value from the above query. i use randtange to get the radom value.

I am able to do it without CFC but when i embedde in cfc i get numerrous issues.

I know it can be done by making the one cfc method private but don't know the exact way around

Can some one guide me plz

Cheers
This topic has been closed for replies.

1 reply

Inspiring
November 11, 2008
it is not very clear what you mean...
are the 2 queries in the same cfc method or in different methods?

if they are in 2 different methods (functions) of the same cfc, then
just call the first function from the second function to get the result
o the first function into a var:

<cfcomponent>

<cffunction name='f1' returntype='numeric' access='public' output='no'>
<cfset var q1 = ''>
<cfquery name='q1' datasource='...'>
SELECT x FROM y WHERE ...
</cfquery>
<cfreturn q1.recordcount />
</cffunction>

<cffunction name='f2' returntype='numeric' access='public' output='no'>
<cfset var f1q1recordcount = function1()>
<cfreturn f1q1recordcount />
</cffunction>

</cfcomponent>

if function f1 was in a separate cfc, then you just invoke that cfc in
the f2 function via your preferred method, i.e.:

<cffunction name='f2' returntype='numeric' access='public' output='no'>
<cfset objOtherCFC = createobject('component', 'path.to.other.cfc')>
<cfset var f1q1recordcount = objOtherCFC.function1()>
<cfreturn f1q1recordcount />
</cffunction>

hth

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/