This content has been marked as final. Show 9 replies
Have the function in your CFC return a query object or a struct containing first and last name elements.
I was actually thinking of making it generic enough so if the requestor wanted "Last_name" and "Dept", then I would return that and if they wanted "Dept" and "Manager_Name", then I would return that. So the caller of the cfc would be in control and ask for what field they want.
So is there a way to tell the object what you want to have returned back?
You could provide the field names desired as an array in an argument then build the query as shown below. I do not recommend this however as you are vulnerable to SQL injection attack unless you are careful about what gets into your array.
Alternatively if you only execpt one row to be returned you could use a struct to return only the fields you desire.
What you have provided me is great.
Would I then call my cfc using the code below?
How would I know what the developer is going to be asking for? I need a way for them to tell me from the <cfinoke> in order for the CFC to know what to return. The calling part is what is puzzling me. The ability to accept different field name from the caller and send them back what they asked for.
See code below
Let me try it and see if I can get it working.
Thanks so much.
Minor typo correction. Don't forget to VAR the function variables :-)
<cfset VAR local=StructNew() />
Good catch cf_dev2. Yes, always var scope within cffunction.