Title: RE: [CFCDev] Detecting arguments passed by CFINVOKEARGUMENT?

Have you tried parsing the arguments structure inside the CFC?  This'll tell you everything that is passed.

Another approach is to pass a structure with the fields you need in the where clause (along the lines of what Raymond suggested):

i.e. this is a variation of the code I currently use.  works pretty good.


test.cfm

                <cfscript>
                        ...

                        mySQL = structNew();
                        mySQLFieldIndex = 1;

                        mySQL[mySQLFieldIndex] = structNew();
                        structInsert(mySql[mySQLFieldIndex], "field", "firstname");
                        structInsert(mySql[mySQLFieldIndex], "value", "howard");
                        structInsert(mySql[mySQLFieldIndex], "data_operator", "=");
                        mySQLFieldIndex = incrementValue(mySQLFieldIndex);

                        mySQL[mySQLFieldIndex] = structNew();
                        structInsert(mySql[mySQLFieldIndex], "field", "lastname");
                        structInsert(mySql[mySQLFieldIndex], "value", "fore");
                        structInsert(mySql[mySQLFieldIndex], "data_operator", "=");
                        mySQLFieldIndex = incrementValue(mySQLFieldIndex);                     
                       
                        qResults = foobar.getAllDetailWhere(whereStruc=mySQL); 

                        ...
                       
                </cfscript>

foobar.cfc
                ...

                <cfquery name="results" datasource="#this.datasource#">
                        select  *
                        from            #this.tablename#
                        <cfloop index="i" from="1" to="#structCount(whereStruc)#">
                        <cfif i EQ 1>
                                where   #whereStruc[i].field# #whereStruc[i].data_operator#
                                <cfqueryparam value="#whereStruc[i].value#">
                        <cfelse>
                                and     #whereStruc[i].field# #whereStruc[i].data_operator#
                                <cfqueryparam value="#whereStruc[i].value#">
                        </cfif>
                </cfquery>
                ...

HTH

-----Original Message-----
From: Howard Fore [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 01, 2003 11:31 AM
To: [EMAIL PROTECTED]
Subject: [CFCDev] Detecting arguments passed by CFINVOKEARGUMENT?


Howdy,

Is there any way to detect what arguments are passed into a CFC via
CFINVOKEARGUMENT? I have a CFC that represents an object that can be
looked up in the database by several different combinations of fields
(for instance (username and password) or (first name and last name and
studentNumber) or (studentSequence)). How can I determine which
arguments are being used for a given invocation? These fields are
defined in the CFC by CFPROPERTY, which seems to automagically define
those fields in the CFC's argument struct.

--
Howard Fore, [EMAIL PROTECTED]
"Perception is reality; please make sure your perception isn't the
product of a designed reality"

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev'
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

Reply via email to