EasyCFM.COM ColdFusion Forums / Coding Help! / What Is <cftransaction>

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: What Is <cftransaction>

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

cybercompros
03-15-2004 @ 6:50 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 320
Joined: Feb 2004

Ok this is not a hard question since ive seen what it can be used for but i want to know more about it!  What exactly is   <cftransaction> and what is it used for besides holding a million <cfquery>'s as i seen it used to do!?

The Example I Seen (FROM CF_NUKE)
  <cftransaction>
  <cfquery name="updatesettings" datasource="#dsn#">
     update tbl_cfnuke_sitesettings
     set fld_regapproval = '#form.approve_reg#',
         fld_siteURL = '#form.siteURL#',
         fld_newsapproval = '#form.approve_news#',
         fld_reviewapproval = '#form.approve_review#',
         fld_quotesapproval = '#form.approve_quote#',
         fld_newsnumber = '#form.news_num#',
         fld_reviewsnumber = '#form.reviews_num#',
         fld_shortreviewnumber = '#form.shortrev_num#'
     where fld_settingid = 1
   </cfquery>
   <cfquery name="setdefaulttheme" datasource="#dsn#">
     update tbl_cfnuke_sitethemes
     set fld_themedefault = 'Yes'
     where fld_themeid = #form.defaulttheme#         
   </cfquery>
   <cfquery name="resetdefaulttheme" datasource="#dsn#">
     update tbl_cfnuke_sitethemes
     set fld_themedefault = 'No'
     where fld_themeid <> #form.defaulttheme#         
   </cfquery>
  </cftransaction>


usually i got to the tags section of the site, but i couldnt seem to find the tag in the area!

Jordon Bedwell
Cybercom Pros
------------------------------
Texas Design! Texas Pride!

wWw.JoRdOnBeDwElL.CoM


This message was edited by cybercompros on 3-15-04 @ 6:58 AM

maquiladoras
03-15-2004 @ 7:07 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 2073
Joined: Dec 2002

CFTransaction for memory, is basically, you either execute all of it, or nothing at all
its basically so if you have 2 Queries,
Query1 and Query2, and Query2 will run whether query1 works or not BUT Query2 to work properly needs Query1 to work , then it'll make sure it doesn't execute

-
"There is no justice, There is Just Us"
-

maquiladoras
03-15-2004 @ 7:10 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 2073
Joined: Dec 2002

http://livedocs.macromedia.com/coldfusion/6/CFML_Reference/Tags-pt315.htm

-
"There is no justice, There is Just Us"
-

megan
03-15-2004 @ 12:15 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 2398
Joined: Jan 2003

Hi Jordon - basically you use it when you need several things done as a unit, where when to accomplish your task you need to do it in more than one step, but all the steps are really one thing - for example you need to insert a record where the id is autonumber but then you need to requery after the insert to get that new id so you can then insert it into another table as a foreign key - if another record was accidently inserted between those two steps it would make for errors in your second insert, so you would hold the two step together with cftransaction.


btw - you can save time with maquiladoras suggestion and look up any tag you are curious about in the livedocs ~megan



Estne tibi forte magna feles fulva et planissima?

cybercompros
03-15-2004 @ 12:29 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 320
Joined: Feb 2004

Oh ya, i like <cftransaction> and <cflock> they make me happy, i shoulda be introduced to those tags along time ago!

Jordon Bedwell
Cybercom Pros
------------------------------
Texas Design! Texas Pride!

wWw.JoRdOnBeDwElL.CoM


Website Designed and Developed by Pablo Varando.