ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 1st, 2009, 03:37 PM
loki421 loki421 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2008
Location: Bromsgrove
Posts: 88 loki421 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 39 m 44 sec
Reputation Power: 2
Question Building array from orderedlist query???

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.

Reply With Quote
  #2  
Old July 1st, 2009, 04:37 PM
loki421 loki421 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2008
Location: Bromsgrove
Posts: 88 loki421 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 39 m 44 sec
Reputation Power: 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

Reply With Quote
  #3  
Old July 8th, 2009, 10:20 AM
Master__Chief Master__Chief is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2005
Posts: 261 Master__Chief User rank is Sergeant Major (2000 - 5000 Reputation Level)Master__Chief User rank is Sergeant Major (2000 - 5000 Reputation Level)Master__Chief User rank is Sergeant Major (2000 - 5000 Reputation Level)Master__Chief User rank is Sergeant Major (2000 - 5000 Reputation Level)Master__Chief User rank is Sergeant Major (2000 - 5000 Reputation Level)Master__Chief User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 3 h 45 sec
Reputation Power: 33
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

Reply With Quote
  #4  
Old July 8th, 2009, 10:51 AM
kiteless kiteless is offline
Moderator
Dev Shed Specialist (4000 - 4499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 4,275 kiteless User rank is Lieutenant General (80000 - 90000 Reputation Level)kiteless User rank is Lieutenant General (80000 - 90000 Reputation Level)kiteless User rank is Lieutenant General (80000 - 90000 Reputation Level)kiteless User rank is Lieutenant General (80000 - 90000 Reputation Level)kiteless User rank is Lieutenant General (80000 - 90000 Reputation Level)kiteless User rank is Lieutenant General (80000 - 90000 Reputation Level)kiteless User rank is Lieutenant General (80000 - 90000 Reputation Level)kiteless User rank is Lieutenant General (80000 - 90000 Reputation Level)kiteless User rank is Lieutenant General (80000 - 90000 Reputation Level)kiteless User rank is Lieutenant General (80000 - 90000 Reputation Level)kiteless User rank is Lieutenant General (80000 - 90000 Reputation Level)kiteless User rank is Lieutenant General (80000 - 90000 Reputation Level)kiteless User rank is Lieutenant General (80000 - 90000 Reputation Level)kiteless User rank is Lieutenant General (80000 - 90000 Reputation Level)kiteless User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 2 Weeks 6 h 56 m 26 sec
Reputation Power: 896
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Building array from orderedlist query???


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek