Not to beat a dead horse, since you seem to be happy with your solution,
but if elegant is a goal I would have gone with merging all the queries
into a single query inside the cfc, then queryOfQuery it for the sort you
wanted, returning the merged master query as a single entity, as that's
about as simple as you can get to work with for output.

Regarding your comment about this:

<cfset myCFC.addQuery(qry1, "qry1")>
> and
>
<cfset myCFC.addQuery("qry1", qry1)>
>

Never underestimate the power of named arguments:
<cfset myCFC.addQuery(query=myQuery,name="myQuery")>

I personally wouldn't do this exactly (that is, require that a method call
be TOLD something that it cannot or should not have to infer from the input
data), but the point is that using named arguments clears up a lot of
ambiguity, is easier to read and understand at a glance, and mitigates the
problems associated with positional arguments in your custom objects.



On Tue, Jul 10, 2012 at 7:46 PM, Matt C <[email protected]> wrote:

> Wow, lol, too many replies to respond to individually, but thank you all
> for the feedback.  I have a much more elegant solution than my original CFC
> goal, but I still wanted to challenge myself to see if I could make this
> other way work as well.
>
> Just for the record, my exact original intent was for my CFC to take
> multiple queries, completely unrelated except they all contain a specific
> date field, and return a two-dimensional array that orders the records from
> all the queries in chronological order relative to one another.  The first
> dimension would indicate which query to look at, and the second dimension
> would identify the index.  Then for each record, the user could use the
> first dimension to decide what additional data is available.
>
> The original hope was for my CFC to be useable by the most basic of CF
> programmers (IE someone not familiar with Structs, etc).  In other words, I
> would have liked to set it up so the user could say...
>
> <cfset myCFC.addQuery(qry1)>
> <cfset myCFC.addQuery(qry2)>
> <cfset myCFC.addQuery(qry3)>
> <cfset newOrder = myCFC.doYourThing()>
>
> <cfloop index="i" from="1" to="ArrayLen(newOrder)">
>     <cfif newOrder[i][1] EQ "qry1">
>         (display specific qry1 info at index newOrder[i][2])
>     <cfelseif newOrder[i][2] EQ "qry2">
>         (display specific qry2 info at index newOrder[i][2])
>     etc etc...
> </cfloop>
>
> I think the easiest work-around there would be to have the user specify
> the name as a second parameter at the same time as they add the query to
> the CFC.  But I just wanted to make sure I wasn't missing something that
> would allow me to prevent that extra step for the user.  Afterall, who
> wants to explain the difference between...
>
> <cfset myCFC.addQuery(qry1, "qry1")>
> and
> <cfset myCFC.addQuery("qry1", qry1)>
>
>
>
> --
> online documentation: http://openbd.org/manual/
> http://groups.google.com/group/openbd?hl=en
>

-- 
online documentation: http://openbd.org/manual/
 http://groups.google.com/group/openbd?hl=en

Reply via email to