Solved

Call nested functions, looping through returned queries

Posted on 2009-07-09
4
203 Views
Last Modified: 2013-12-24
I'm calling a CFC through a RemoteObject call which passes an ID. Within that function I need to call another function based on the ID. That function returns a query which I then loop through to continuously call another function, which also returns a query, which again calls another function...I'm not sure how to get started...


<cfargument name="_ID1" type="numeric" required="yes">

<cfargument name="_ID2" >

<cfargument name="_1stQ" type="query">

	

<cfset _1stQ= getFirstQuery(#_ID1#)>

		

<cfloop query="_1stQ">

<cfset _get2ndQ= getSecondQuery(#_ID2#)>

</cfloop>

Open in new window

0
Comment
Question by:coldchillin
4 Comments
 
LVL 27

Assisted Solution

by:azadisaryev
azadisaryev earned 200 total points
ID: 24820111
you are on the right track! that's exactly how one does this, assuming all the other functions you call are in the same cfc.

just don't forget to VAR-scope all variables you create in your function. i.e. in your above code you will need to add <cfset var _get2ndQ = ""> just after the last <cfargument> tag.

also, no need for those # in function calls.

Azadi
0
 
LVL 13

Assisted Solution

by:srikanthmadishetti
srikanthmadishetti earned 150 total points
ID: 24822140
when you are looping the first query  and getting the second query

<cfset _get2ndQ= getSecondQuery(#_ID2#)>


what is this _ID2  is this you pass as an argument or a column of the query which is returned in first query call.

if an argumen which is passed , so in the loop every time ur passing the same variable.

you will be getting out put same query.

if it is a column of the firstquery and u want to pass dynamically to this call


<cfset _get2ndQ= getSecondQuery(#_ID2#)>

you don't need to actually delcare that in arguments section.

and more over where are you storing this query object which you are getting in the loop.



0
 
LVL 39

Assisted Solution

by:gdemaria
gdemaria earned 150 total points
ID: 24822795
I agree with srikan.. it seems like some details are needed.

I'm assuming the first ID is passed to the function, but the second ID comes from the first query, otherwise the second query would not make sense.

Here's the same code for that, don't forget you need to scope your variables...

<cffunction name="getData">

  <cfargument name="_ID1" type="numeric" required="yes">

  <!--- removed 1stQ and 2nd ID from arguments because it seems they are not passed in, but are created within the function ----->

  

  <cfset var _1stQ= getFirstQuery(arguments._ID1)> <!---- assuming the ID is passed to the function ---->

  <cfset var _get2ndQ = "">

                

  <cfloop query="_1stQ">

    <cfset _get2ndQ = getSecondQuery(_1stQ.ID)> <!--- assuming the ID comes from the first query ---->

  </cfloop>
 

</cffunction>

Open in new window

0
 
LVL 1

Accepted Solution

by:
coldchillin earned 0 total points
ID: 24938383
Actually, I ended up simply invoking the other methods using a cfinvoke, returning a query, which I then looped and invoked yet another query, and so on... but thanks for all the help!
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now