ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

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 March 5th, 2012, 04:33 PM
ColdBreeze ColdBreeze is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Posts: 29 ColdBreeze User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 56 m
Reputation Power: 0
Complex object types cannot be converted to simple values?

I want to loop through the results of a query:

Code:
<cfloop index="x" from="1" to="23">
    <cfif queryReturn["queryVariable#x#"] neq false>
        <!--- do stuff here --->
    </cfif>
</cfloop>


This will toss a "complex object types cannot be converted to simple values" exception since it does not like the queryReturn["queryVariable#x#"] part. Anyway around this?

Reply With Quote
  #2  
Old March 5th, 2012, 05:10 PM
kiteless kiteless is offline
Moderator
Dev Shed God (5000 - 5499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 5,100 kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 4 h 29 m 54 sec
Reputation Power: 966
<cfif queryReturn["queryVariable"][x] neq false>

Reply With Quote
  #3  
Old March 7th, 2012, 08:41 AM
ColdBreeze ColdBreeze is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Posts: 29 ColdBreeze User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 56 m
Reputation Power: 0
Thank you, that looks like it should do the trick but... it looks like it loops through everything that ends in whatever I name "queryVariable". Say I have "queryVariable1" through "queryVariable23", this will toss an error if I have another variables named "anotherQueryVariable". It'll say that "anotherQueryVariable" is not indexable by "queryVariable".

Reply With Quote
  #4  
Old March 7th, 2012, 09:14 AM
kiteless kiteless is offline
Moderator
Dev Shed God (5000 - 5499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 5,100 kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 4 h 29 m 54 sec
Reputation Power: 966
I don't really understand what you're saying. If you run this query and name it "myQuery":

select id, userName, isActive from users

If you then do this, it will work fine:

Code:
<cfloop index="x" from="1" to="#myQuery.recordCount#">
    <cfif myQuery["isActive"][x] eq false>
        <!--- this user is not active --->
    </cfif>
</cfloop>

Reply With Quote
  #5  
Old March 9th, 2012, 10:48 AM
ColdBreeze ColdBreeze is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Posts: 29 ColdBreeze User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 56 m
Reputation Power: 0
Whenever it hits the last column name, it just says it is not indexable by whatever I put in myQuery["isActive"][x]. I'm selecting everything out of the query, since I kind of have to with what I'm doing. There is probably about 40 columns, and 23 of those are checkboxes that have a boolean value. I'm just wanting to loop through just those instead of hardcoding them.

Reply With Quote
  #6  
Old March 9th, 2012, 11:02 AM
kiteless kiteless is offline
Moderator
Dev Shed God (5000 - 5499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 5,100 kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 4 h 29 m 54 sec
Reputation Power: 966
OK what you didn't make clear before is that you're not looping over the result set, you're looping over COLUMNS for each ROW of the result set.

Try something like this:

Code:
<cfloop index="thisRow" from="1" to="#myQuery.recordCount#">
	<cfloop index="thisColumn" from="1" to="23">
		<cfoutput>Value of queryReturn["queryVariable#thisColumn#"][#thisRow#] is : #queryReturn["queryVariable#thisColumn#"][thisRow]#<br/>
	</cfloop>
</cfloop>

Reply With Quote
  #7  
Old March 9th, 2012, 11:25 AM
ColdBreeze ColdBreeze is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Posts: 29 ColdBreeze User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 56 m
Reputation Power: 0
Worked like a charm! Thanks very much!

Edit: I never did anything like this. So I'm guessing we had to place the row as the index so that it would know where to go.

Code:
queryResults["queryVariable#thisColumn#"][#thisRow#] 

Columns 1 through 23 of row whatever.

Reply With Quote
  #8  
Old March 9th, 2012, 12:12 PM
cfSearching cfSearching is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 117 cfSearching User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 h 16 m 2 sec
Reputation Power: 6
Quote:
Originally Posted by ColdBreeze
So I'm guessing we had to place the row as the index so that it would know where to go.


Yes. queryResults["queryVariable#thisColumn#"] points to a column object, not a simple string. It is similar to a one dimensional array, with each element representing a row value. So the index (ie row number) tells CF which value to retrieve.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Complex object types cannot be converted to simple values?

Developer Shed Advertisers and Affiliates



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

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


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap