feeling like a nub.. an awesome feature existed since coldfusion 7

Yep, I feel like I know coldfusion pretty well. Well I thought I did...

Today, I was looking over cfquery (and now I forget why), but noticed there is an attribute called "RESULT".  I guess I need to go over all the things added since CFMX.

But anyways I quickly wrote a quick page to do insert, select, and delete.

<cfquery name="iRtr" datasource="commons" result="rRtr">
 insert into staff.dbo.test (testData)
 values('test1')
</cfquery>
<cfdump var="#rRtr#">

<cfquery name="qRtr" datasource="commons" result="rRtr">
 SELECT * 
 FROM staff.dbo.test
</cfquery>
<cfdump var="#qRtr#">
<cfdump var="#rRtr#">

<cfquery name="dRtr" datasource="commons" result="rRtr">
 delete
 FROM staff.dbo.test
</cfquery>
<cfdump var="#rRtr#">

And to my suprise, there were some really cool things that appeared. Like the value of the identity column, how many rows were inserted/deleted. Just amazing!  Here is the output of the query above.

Comments

  1. "Result" is a cool property. I believe it exists for any ColdFusion tag that also creates an implicit variable in the page. Example, CFHTTP, CFFile[upload]. I use Result with CFHTTP all the time. It feels so much cleaner than using the "cfhttp" object that get's created.

    ReplyDelete
  2. Thanks Ben, the next time I deal with those tags, i'll have to try to use the results attribute!

    ReplyDelete

Post a Comment

Popular posts from this blog

ColdFusion in an Enterprise Environment - Part 1 - Understanding how to use SubVersion (SVN)

coldfusion builder 2 extension not displaying browse button on type=projectdir

Being Thread Safe in Coldbox/Coldfusion