<cftransaction>

Groups multiple queries into a single unit.

The cftransaction tag provides commit and rollback processing.

This tag must have a body.

This tag is also supported within <cfscript>

<cftransaction action=begin|commit|setSavePoint|rollback isolation=string ><!--- body ---></cftransaction>
Attribute Description
action
string, optional
  • begin: The start of the block of code to execute.
  • commit: Commits a pending transaction.
  • rollback: Rolls back a pending transaction.
  • setsavepoint: Saves a specific state within a transaction
isolation
string, optional

Database lock type.

  • read_uncommitted
  • read_committed
  • repeatable_read
  • serializable
  • none

https://en.wikipedia.org/wiki/Isolation_(database_systems)

Examples

<cffunction name="updateAddress" access="remote" output="false">
  <cfargument name="addressId" type="number" required="yes">
  <cfargument name="newAddress" type="string" required="yes">

<cftransaction isolation="read_committed"> <cfquery name="changeAddress" datasource="#application.config.DSN#"> update address set login_address = <cfqueryparam value="#arguments.newAddress#" cfsqltype="VARCHAR"> where id = <cfqueryparam value="#arguments.addressId#" cfsqltype="INTEGER"> </cfquery> </cftransaction> </cffunction>

See also