After a query has run, you have access to the queryname.columnlist variable, which is, as its name would suggest, a list of columns in the query.
Also, I wouldn't label CFML an aracane or esoteric language. There's a comparable amount of introductory information on how to use CFML as there is for PHP or ASP. I'm certain that you are correct in assuming that we will all be happy to help you learn and most everyone is always happy to welcome new developers into the fold. Also, if you have not yet discovered the Live Docs, you'll be able to find all kinds of answers there. http://livedocs.macromedia.com/ --Ferg >Oh great masters of ColdFusion, a humble beginner beseeches your help. Oh >great masters of this arcane language, how do I count the number of columns in >a given table? > >In PHP, all I have to do is to invoke mysql_num_fields(), and I'm done without >further ado. In ColdFusion, I have to count them by first sending a query >before getting the result's column names. I have to do something like this: > ><cfquery name="qtest" datasource="foo"> > select * from data limit 1 ></cfquery> > ><cfoutput> > The number of columns is: #ListLen(qtest.ColumnList)# <br /> ></cfoutput> > >This works, although this doen't look elegant (IMHO). Do you guys have better >solutions? > >In addition, how do I manipulate the nth column of any given table? The >solution I've found (so far) is to use ListGetAt() such that: > ><cfquery name="tblPointer" datasource="simoncpu_shop"> > <cfoutput> > select `#ListGetAt(test.ColumnList, 1)#` from data > </cfoutput> ></cfquery> > >The problem is, ListGetAt() returns the list in alphabetical order--in other >words, that function does not return the list in the correct order! You see, >I'm creating a ColdFusion app that constantly alters the data's categories, >and I implemented the categories as the table's individual columns. > >One may argue that this is a serious database design flaw. The argument is >probably correct, but please note that I'm just experimenting with ColdFusion >in order to learn more about this language (I've only started this month). > >ColdFusion is not so hard compared to other scripting languages. The >challenge, I think, is not on how to learn it; but rather, the challenge is to >learn how to be open-minded in adopting it. I hope I won't offend anyone in >this list, but I had to keep myself from having an *ehem* un-nice *ehem* >reaction when I first encountered features such as <cfform>, <cftable>, ><cfquery>, and other tags that uhm, makes our lives, uhm, easier. :) > >Anyway, I'm starting to love this language because ColdFusion DOES make our >lives easier. I hope you guys can help me with my transition. Thanks for >your time. > > >[ simon.cpu ] > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:207733 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

