1 Reply Latest reply on Nov 11, 2008 1:02 AM by Newsgroup_User

    A Quick CFC Help?

    newchickinCF Level 1
      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
        • 1. Re: A Quick CFC Help?
          Level 7
          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/