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:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old September 23rd, 2004, 03:52 AM
FrozenShade FrozenShade is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 10 FrozenShade User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Converting query to comma separated list

First question, though I suspect this might not be the best approach ...is it possible to turn a query (cfdirectory in this case) into a comma separated list?

The reason I ask is bcos currently I have a hardcoded list of folders in my action file, and I loop through and pull all the files from each. Like so...

<cfloop
index = "thisItem"
list = "maps,districtPlans,mgmtPlans">

<cfdirectory
name="getAllFiles"
action="list"
directory="#serverdir##thisItem#"
sort="name ASC">

<cfquery dbtype="query" name="getAllFiles_#thisItem#">
SELECT *
FROM getAllFiles
</cfquery>

</cfloop>

and in the display page something like...
<ol>
<cfoutput query="getAllFiles_maps">
#replace(listFirst(name), "_", " ", "ALL")#<br />
</cfoutput>
</ol>

<ol>
<cfoutput query="getAllFiles_mgmtPlans">
#replace(listFirst(name), "_", " ", "ALL")#<br />
</cfoutput>
</ol>
--------------------

This is all working fine...My question is two-part really. Instead of hardcoding the list, I can do another directory call like so...

<cfdirectory
name="getAllFolders"
action="list"
directory="#serverdir#"
sort="name ASC">

which will give me all the folders that are in the above list (ie maps,districtPlans etc). So, how to get the query to a list so I don't need to hardcode? OR, is this the wrong approach and is it possible to use the getAllFolders query directly in some fashion?

TIA
Mark

Reply With Quote
  #2  
Old September 23rd, 2004, 05:22 AM
FrozenShade FrozenShade is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 10 FrozenShade User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Here's what seems to work....

<cfdirectory
name="getAllFolders"
action="list"
directory="#serverdir#"
sort="name ASC">

<cfloop query = "getAllFolders">

<cfdirectory
name="getAllFiles"
action="list"
directory="#serverdir##name#"
sort="name ASC">

<cfquery dbtype="query" name="getAllFiles_#name#">
SELECT *
FROM getAllFiles
</cfquery>

</cfloop>

adieu
Mark

Reply With Quote
  #3  
Old September 23rd, 2004, 07:16 AM
Shiju Rajan's Avatar
Shiju Rajan Shiju Rajan is offline
.Net Developer
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2000
Location: London
Posts: 987 Shiju Rajan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 26 m 22 sec
Reputation Power: 9
Send a message via MSN to Shiju Rajan Send a message via Yahoo to Shiju Rajan
I think what you are doing is correct. that is the best way to pull out all the directory structure.

I have just changed your code a bit here.

Code:
<cfdirectory 
name="getAllFolders"
action="list"
directory="#serverdir#"
sort="name ASC">


<cfloop query = "getAllFolders">

<!--- process only directories and escape root . directories --->
<cfif type eq "Dir" and name neq "." AND name neq "..">
<strong><cfoutput>#name#</cfoutput></strong> :

<cfdirectory
name="getAllFiles"
action="list"
directory="#serverdir##name#"
sort="name ASC">

<!--- exclude dir name . and .. --->
<cfquery dbtype="query" name="qry_getAllFiles">
 SELECT * FROM getAllFiles Where name not in ('.','..')
</cfquery>

 
 <ol>
 <cfoutput query="qry_getAllFiles">
 #replace(listFirst(name), "_", " ", "ALL")#<br/>
 </cfoutput>
 </ol>
</cfif>  
</cfloop>
__________________
SR -
webshiju.com
www.lizratechnologies.com

"The fear of the LORD is the beginning of knowledge..."

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Converting query to comma separated list


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway