Hey guys, I'm trying to create a CFC which allows me to input two table names
and two datasources and return to me the differences of the two tables. I want
to return any differences in the columnList, and also the records.
I'll be able to handle the logic to do that, but am a little confused about
how to approach the CFC. So I have a form page with 4 fields, Table1, Table2,
DSN1, DSN2 - The user will give the dsn and tablenames they want to compare.
How would you approach this. Should my CFC have 1 function ...

My first CFC - a little help.

Hey guys, I'm trying to create a CFC which allows me to input two table names
and two datasources and return to me the differences of the two tables. I want
to return any differences in the columnList, and also the records.

I'll be able to handle the logic to do that, but am a little confused about
how to approach the CFC. So I have a form page with 4 fields, Table1, Table2,
DSN1, DSN2 - The user will give the dsn and tablenames they want to compare.

How would you approach this. Should my CFC have 1 function which does all the
logic and return 4 parameters back? Not clear on the syntax with this, can I
use multiple CFRETURNS in one function?

The examples I found online only cosisted of 1 function returning 1 variable.
I understand this, but I need to return more then 1.

Re: My first CFC - a little help.

"can I use multiple CFRETURNS in one function?"

No.

Either break each return out into a separate function, or have the result be
stored in CFC member variables and access the results using get___ calls, or
store all 4 results in a structure, indexed by the name of the result.

Re: My first CFC - a little help.

Let me give you the real world scenario I'm facing, as I think if you explain
it it's going to benefit me a lot.

Let's just say I wanted to, upon a form post, get the columnList of table1 and
the list of table2, just 2 variables.

So my first page has 2 form fields, table1 and table2, the user enters those
in and the form is posted to a page which invokes my CFC. - This is the part I
am confused on. Do I call multiple functions to return 2 vars? If so, how? or
would I just return 1 variable with 2 seperate lists.

Re: My first CFC - a little help.

Well, one possible problem is that you're naming your queries the same as some
arguments coming in. It's never good style to use the same name for different
things. Either it's an argument, or a query.

As far as <cfinvoke>, I've never used it with argumentcollection before. What
is the contents of tableCols before you call <cfinvoke>?

Re: My first CFC - a little help.

Hi Kron,

Ok, so I ripped out all the component stuff to debug and figured out the
structure is having difficulties storing the values. I validated this by
outputing the var's on their own to validate that they work.

As you can see, I'm outputting the columnlist of the queries and it's working
fine. When I try and output the structure using
<Cfoutput>#tableCols#</cfoutput> it breaks and give me the following error.

Re: My first CFC - a little help.

Re: My first CFC - a little help.

Gotcha, but then I'm confused as to how to pass the structure out of the
component to reference it on my next page. Here's my code, let me know how to
output the structure on the next page. Basically, I want to compare the
columnlists and display to the user any columns in table 2 not in table 1.

Re: My first CFC - a little help.

Re: My first CFC - a little help.

Blastbeat, when you are writing your own functions, whether inside a component
or elsewhere, it is to your advantage to use the var keyword when setting
variables. In your case, this:
<cfset tableCols = StructNew() />
shoud be this:
<cfset var tableCols = StructNew() />

The reason is that if tableCols is declared as a variable before your method
is invoked, your method will overwrite the variable. The var keyword keeps the
variable local to the function.