<cfset properties = myCfc.getAgentProperties(agentId) />
<cfif properties.recordCount LT 20>
  <cfset otherProperties = myCfc.getArbitraryProperties(count: 20 -
properties.recordCount, excludeAgentId: agentId) />
  <cfquery dbtype="query" name="properties">
      select * from properties
    union
      select * from otherProperties
  </cfquery>
</cfif>

<!--- 'properties' now contains 20 records --->

In general, your CFC methods should never access any external scopes
(session, request, application, cookie, cgi, etc.), unless the CFC's
purpose is explicitly to wrap those scopes.  All input/output from a
CFC's methods should be in the form of arguments and the return value.

cheers,
barneyb

On Mon, Jun 16, 2008 at 7:57 PM, Rick Faircloth
<[EMAIL PROTECTED]> wrote:
> Hi, all...
>
> I want to first thank everyone for the help and encouragement
> you've given while I try to learn to use cfc's.
>
> I'm trying to figure out the best way to solve this problem.
>
> I've got a real estate agent page that displays their properties.
> Sometimes they only have a few, or none.
>
> What I want to do is determine how many properties they have displayed
> and then, if it's less than 20, run another query that grabs the
> number of properties equal to the difference between 20 and the
> number of their displayed properties.  The idea is to have 20 properties
> on an agent's page, some will be their listings, others not.
>
> I've got the first query for the agents' properties in a cfc called,
> "get_agent_properties".
>
> I was setting up another function called, "get_extra_properties", but
> I wasn't sure how to get a variable (argument) back to this function
> from the first function.
>
> Should I run the first query, get the record count and just use this:
>
> <cfif get_agent_properties.recordcount lt 20>
>
>        <cfset session.extra = 20 - get_agent_properties.recordcount>
>
> and on the invoking page, just use:
>
> <cfif session.extra gt 0>
>
>        ...invoke the "get_extra_properties" function, using session.extra
>        as an argument for how many properties to get in the query
>
> </cfif>
>
> ???
>
> Is this approach worth pursuing or is there a better way to handle the 
> variables?
>
> Thanks for any feedback.
>
> Rick
>
>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:307585
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to