Not that this post was originally about using cftransaction, but isn't the
try/catch stuff unnecessary because of the nature of the cftransaction tag
itself? That's what I thought. I could be dead wrong. ;o)

Chris

On 7/26/07, Chris Gomez <[EMAIL PROTECTED]> wrote:

One of the better ways I've found to handle transactions using CF is like
this:

<cflock name="AddOrder" timeout="10">
  <cfset commit = true>
  <cftransaction action="begin">
  <cftry>
    <cfquery>
       blah blah
   </cfquery>
   <cfquery>
     blah blah
   </cfquery>
   <cfcatch type="any">
    <cfset commit = false>
    <cftransaction action="rollback" />
    <cflocation addtoken="false" url="errorpage.cfm">
   </cfcatch>
  </cftry>
  <cfif commit>
    <cftransaction action="commit" />
    <cflocation addtoken="false" url="success.cfm">
  </cfif>
  </cftransaction>
</cflock>

The transaction is only added to the db if every query or function is
successful. This prevents multiple transaction sessions from interfering
with each other and disallows partial inserts/updates/etc (like in a
shopping cart solution) from being entered in to the db.

Hope this helps.

Chris

On 7/26/07, Christopher Jordan <[EMAIL PROTECTED]> wrote:
>
> Kevin,
>
> I'm not an authority, but here's what I think I know:
>
> INNODB tables are slower *because* they allow for transactions.
> Transactional databases (tables?) allow you to roll back changes that were
> made to it. So it keeps track of all changes that have been made and store
> them so that you can roll back a particular insert or update or what have
> you as if that statement had not taken place. I have no idea how far back it
> keeps information of this sort, I just know that on other DBs I've worked
> with (older versions of DB2) this means that extra disk space is required to
> store all the changes.
>
> The only senario that *I'm* aware of (I'm sure there are loads more)
> would be when doing something like this:
>
> <cftransaction>
>     <cfquery name="update" datasource="blahblah">
>         UPDATE InventoryTable
>         SET ItemQuantity = ItemQuantity - 1 -- I think you can do this
> in sql... if not just consider it psuedo code ;o)
>         WHERE ItemID = #MyItemID#
>     </cfquery>
>     <!--- customers automattically get entered for a prize drawing or
> something --->
>     <cfquery name="insert" datasource="blahblah">
>         INSERT INTO PrizeDrawingTable (CustomerID, ItemID)
>         VALUES (#MyCustomerID#, #MyItemID#)
>     </cfquery>
> </cftransaction>
>
> In this case if the first query fails for some reason, then the second
> query wouldn't execute. If the first query was successful but the second
> query failed, then the first query would be 'Undone' or rolled back.
>
> This may be an overly simplistic view, and since I don't do this sort of
> thing often, I may have even gotten something wrong. Someone please correct
> me if I did get something wrong.
>
> Does that help?
>
> Cheers,
> Chris
>
>  On 7/26/07, Kevin < [EMAIL PROTECTED]> wrote:
>
> >   Anyone have experience with MySQL?  I have been using it for years
> > now but I wonder if I might have outgrown it.
> >
> >
> >
> > The way that I understand it is that my MyISAM tables are faster but
> > INNODB allow for transaction support (which I have never fully understood).
> >
> >
> >
> >
> > We have been using MyISAM for years and have been satisfied.  However,
> > I am told that in order to make a backup of the database you have to shut it
> > down, back it up, then restart it.  This is absurd.  Therefore, we were
> > considering moving to INNODB but everything I read says that these are
> > *VERY* slow tables.
> >
> >
> >
> > Please let me know if you have any advise….should we move away from
> > MySQL?   Is there a solution to back up MyISAM?  Is the performance of
> > INNODB really not as bad as I have read.
> >
> >
> >
> > I am so confused and frustrated……I understand that MySQL is used by
> > some pretty big hitters (http://www.mysql.com/customers/ ).  What are
> > these guys using?
> >
> >
> >
> >
> >
> >
> >
> > Any help, advise, comments, etc. will be tremendously appreciated.
> >
> >
> >
> >
> >
> > --------------------------------------------------------
> >
> >
> >
> > Kevin Fricke
> >
> > Lone Star Media
> >
> > [EMAIL PROTECTED]
> >
> > Office: (512) 371-1822
> >
> > Mobile: (512) 626-0528
> >
> > Fax: (512) 597-0909
> >
> > Toll Free: (877) 791-7083
> >
> >
> >
> > http://www.lonestarmedia.com
> >
> >
> >
> >
> >
> >
> >
> > _______________________________________________
> > Reply to DFWCFUG:
> >   [email protected]
> > Subscribe/Unsubscribe:
> >  http://lists1.safesecureweb.com/mailman/listinfo/list
> > List Archives:
> >     http://www.mail-archive.com/list%40list.dfwcfug.org/
> >   http://www.mail-archive.com/list%40dfwcfug.org/
> > DFWCFUG Sponsors:
> >   www.instantspot.com/
> >   www.teksystems.com/
> >
> >
>
>
> --
> http://cjordan.us
> _______________________________________________
> Reply to DFWCFUG:
>  [email protected]
> Subscribe/Unsubscribe:
>  http://lists1.safesecureweb.com/mailman/listinfo/list
> List Archives:
>    http://www.mail-archive.com/list%40list.dfwcfug.org/
>   http://www.mail-archive.com/list%40dfwcfug.org/
> DFWCFUG Sponsors:
>  www.instantspot.com/
>   www.teksystems.com/
>
>


--
"Fortune favors the prepared mind."
- Louis Pasteur
_______________________________________________
Reply to DFWCFUG:
 [email protected]
Subscribe/Unsubscribe:
 http://lists1.safesecureweb.com/mailman/listinfo/list
List Archives:
   http://www.mail-archive.com/list%40list.dfwcfug.org/
 http://www.mail-archive.com/list%40dfwcfug.org/
DFWCFUG Sponsors:
 www.instantspot.com/
 www.teksystems.com/




--
http://cjordan.us
_______________________________________________
Reply to DFWCFUG: 
  [email protected]
Subscribe/Unsubscribe: 
  http://lists1.safesecureweb.com/mailman/listinfo/list
List Archives: 
    http://www.mail-archive.com/list%40list.dfwcfug.org/             
  http://www.mail-archive.com/list%40dfwcfug.org/
DFWCFUG Sponsors: 
  www.instantspot.com/
  www.teksystems.com/

Reply via email to