When I was in 8th grade, my dad coached our girls basketball team. It was a tiny catholic school in Wisconsin, so basically it was a volunteer job for any takers. I remember one game that we were behind 3 points at the end, I was about to shoot a one-and-one free throw, Dad calls a time out. In the huddle he says ‘After Amy makes these free throws…’ and then proceeded to plan out our final strategic move. I laughed and told him that I too had seen Hoosiers, so the psych up didn’t work for me. I missed the free throw and we lost the game. Last night, I wonder what was said to Pat Burrell before he broke that awful streak of no hits through the playoffs to put the World Series go-ahead run at second base. In any case, we can be proud to say that there is now a champion again in Philadelphia.
So after all the fireworks and shouting last night (yes, all the way out in Hatfield people could be heard rejoicing), I watched the taped Obama infomercial, the Daily Show and Colbert Report because I was still excited and couldn’t sleep. It makes for a groggy morning this morning, probably like most ‘Phans’ out there, but off to work again we go, no parades today.
Yesterday I had to look up something that I always forget the code for because I used it in a site we’re currently working on. In Coldfusion, we have cfquery and cfoutput which enables easy database query programming and display. On the most basic level we use cfquery like this:
<cfquery NAME=”qQuery” datasource=”#DSN#” > <!—optionally use username=”#User#” password=”#Password#”>—>
select field1,field2,field3
from tablename
where somefield=<cfqueryparam cfsqltype=”cf_sql_integer” value=”#someintvar#”>
</cfquery>
Then to output the full query, looping through the rows, it’s easy, just use this:
<cfoutput query=”qQuery”>
field1=#qQuery.field1# — field2=#qQuery.field2# — etc…
</cfoutput>
So what happens if you want to just output one field from one row, like if you run a query to get the first name of a person and you have only the person’s ID field, well, you would run the cfquery as normal, and then use an alternate notation form, sometimes called bracket notation — in this example, rownumber is a numeric (integer) variable that is within the recordcount results range(qQuery.recordcount) of the specific row you are looking to return:
<cfoutput>#qQuery[’fieldx’][rowNumber]#</cfoutput>
This is very basic Coldfusion programming information, but I always forget which part of the bracket notation comes first, the row number or the field name, so that’s why I went through the whole Coldfusion query discussion. After all, a statement out of context isn’t very informative at all, it’s just a random statement.