Lucee SQL Transactions Examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
component { | |
this.datasources["employees"] = { | |
class: 'org.gjt.mm.mysql.Driver' | |
, connectionString: 'jdbc:mysql://192.168.33.10:3306/employees?useUnicode=true&characterEncoding=UTF-8&useLegacyDatetimeCode=false' | |
, username: 'employees' | |
, password: "123456" | |
}; | |
this.datasource="employees"; | |
function onRequestEnd(string targetPage) { | |
setting showdebugoutput="true"; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
transaction { | |
query name='employeeCount' { | |
echo("SELECT count(*) FROM employees"); | |
} | |
} | |
</cfscript> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
transaction { | |
query name='employeeCount' { | |
INSERT INTO employees | |
SET | |
} | |
} | |
writeDump(employeeCount); | |
</cfscript> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* My xUnit Test | |
*/ | |
component extends="testbox.system.BaseSpec"{ | |
/*********************************** LIFE CYCLE Methods ***********************************/ | |
// executes before all test cases | |
function beforeTests(){ | |
} | |
// executes after all test cases | |
function afterTests(){ | |
} | |
// executes before every test case | |
function setup( currentMethod ){ | |
} | |
// executes after every test case | |
function teardown( currentMethod ){ | |
} | |
/*********************************** TEST CASES BELOW ***********************************/ | |
function databaseTest(){ | |
query { | |
echo("select count(*) from employees"); | |
} | |
} | |
function basicTransactionTest(){ | |
include template="basic_transaction.cfm"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment