Introduction to Coldfusion Data Structures Part IV – Queries

This is a dedicated thread for discussing the SitePoint article ‘Introduction to Coldfusion Data Structures Part IV – Queries

I used the CurrentRow variable in my inventory page and it works very well. Nice and simple. I have found cf over all very very easy to learn. I started to build my first site with it in November and found it quite easy to pick up.

Great article. I never knew of the “currentrow” variable and I plan to go and use it now for a lot of listings I do. I love query of queries, I was so happy when they put this into the language. I have used it since it first came out.

Glad you all enjoyed it. :smiley: Once you figure out that CurrentRow is there, it will save you a ton of work.

i use currentrow, recordcount, and columnlist all the time, and every once in a while when im trying to speed things up i use the executiontime (i think thats right…)

Is it possible for a loop that is using the columnlist variable to determine datatype?

I was compelled out of fraustration two weeks ago to modify a module written in coldfusion with no prior knowledge of CFM or Web Application Development.

I was able to modify the scripts somehow… and since been in search of an article like this. This is great stuff.

Are there more of this?

I have written several articles, actually, lekan. They can be found in the ColdFusion section of SitePoint. I also have some articles at KodeFusion.com.

B Ye, if you’re checking back here, you can’t determine the datatype directly. You could use functions like IsDate() or IsNumeric() to determine it to some extent. Otherwise, you might be interested in using Meta Data from your database server. Here’s an article on that: http://www.kodefusion.com/article/index.cfm?ArticleID=23

Regarding query of queries…

From the ColdFusion maual… “A Query of Queries is ideal for tables of 5,000 to 50,000 rows”

For larger databases, query of queries becomes impractical. There are ways to acheive the same functionality without the memory consumption however they’re a little more complicated–especially if you’re running MS SQL.

Correct, spiralhead, query of queries is great for small-to-medium-sized projects, I tend to try and find a solution that allows the database server do as much of the work as possible prior to returning anything to ColdFusion…

Great article, this type of stuff should be in the CF help. There is a typo in the listing that iterates through the columns:

GetUsers.ColumnName should be GetUsers.ColumnList

There is a mistake in the code on first page.
<table border=“1”>
<tr>
<cfloop list=“#GetUsers.ColumnName#” index=“column”>
<cfoutput><th>#column#</th></cfoutput>
</cfloop>
</tr>
<cfoutput query=“GetUsers”>
<tr>
<cfloop list=“#GetUsers.ColumnName#” index=“column”>
<td>#Evaluate(column)#</td>
</cfloop>
</tr>
</cfoutput>
</table>

Instead of ColumnName, it should be ColumnList.
Correct method is as shown below

<table border=“1”>
<tr>
<cfloop list=“#GetUsers.ColumnList#” index=“column”>
<cfoutput><th>#column#</th></cfoutput>
</cfloop>
</tr>
<cfoutput query=“GetUsers”>
<tr>
<cfloop list=“#GetUsers.ColumnList#” index=“column”>
<td>#Evaluate(column)#</td>
</cfloop>
</tr>
</cfoutput>
</table>

Interesting article but there is a pitfall on page 1. You can’t output a column’s value using #Evaluate(column)# because if the column name has spaces (which it can in mysql for example) the CF will fail at runtime :frowning:

Designing a database using column names with spaces is the biggest error one can make!

gimme a couple seconds to remember… i have seen lots worse

:cool:

:lol: One of the biggest at least