|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi all,
i have a string that gets passed to a CFC as an ordered list ( using , as the seperator). This then gets looped through the query and should return only records matching the list Code:
<cfargument name="myString" type="string" required="yes">
<cfset modelslist="#arguments.myString#">
<cfloop index="columnToSearch" list="#modelslist#">
<cfquery name="qData" datasource="vl">
SELECT *
FROM myTable
WHERE column3 = #columnToSearch#
</cfquery>
</cfloop>
This should work fine, but the problem is i then need to return the query, i've tried using Code:
<cfreturn qData /> and i've also tried to build an array with some code i found Code:
<cfset myArray = {} />
<cfset myArray.result = arrayNew(1) />
<cfloop query="qData">
<cfset myArray.temp = {} />
<cfset myArray.temp['*'] = qData.* />
<cfset arrayAppend(myArray.result,myArray.temp) />
</cfloop>
<cfreturn myArray.result />
But that gives me an error too. I'm calling this CFC from a Flex apllication (having a little play ) so i don't have much of an error othan 'server proccessing error' 'unable to invoke CFC'Anyone know how i can return the query or how to build my own array from it? Many thanks in avance all ![]() Edited for spelling ![]() Last edited by loki421 : July 1st, 2009 at 03:40 PM. |
|
#2
|
|||
|
|||
|
Ha! I've been as dumb as Fry! lol
![]() The answers easy! I've left out the single quote marks from either side of the #columnToSearch# lol ![]() |
|
#3
|
|||
|
|||
|
I wish flex and coldfusion error handling was a bit better. You can use
Code:
<cftry>
<cfloop index="columnToSearch" list="#modelslist#">
<cfquery name="qData" datasource="vl">
SELECT *
FROM myTable
WHERE column3 = #columnToSearch#
</cfquery>
</cfloop>
<cfcatch>
<cfmail from="me@me.com" to="me@me.com" subject="!! app error !!" type="html">
<cfdump var="#cfcatch#">
</cfmail>
</cfcatch>
</cftry>
This way you can at least see what the real error is. I also remember somebody saying <cfrethrow> might work better. Didn't have a chance to play around with that though...
__________________
www.fuzzysiberians.com |
|
#4
|
|||
|
|||
|
Or use the debugging plugin for Eclipse.
Also, looping over the values and querying for each one separately is extremely inefficient when you could just do this within a single SQL statement using an IN clause or set of OR clauses. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Building array from orderedlist query??? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|