Skip to content

Instantly share code, notes, and snippets.

@roryl
Last active June 6, 2016 12:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roryl/fca1f922ee013a4bfa8b1f67af163620 to your computer and use it in GitHub Desktop.
Save roryl/fca1f922ee013a4bfa8b1f67af163620 to your computer and use it in GitHub Desktop.
Lucee SQL Transactions Examples
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";
}
}
<cfscript>
transaction {
query name='employeeCount' {
echo("SELECT count(*) FROM employees");
}
}
</cfscript>
<cfscript>
transaction {
query name='employeeCount' {
INSERT INTO employees
SET
}
}
writeDump(employeeCount);
</cfscript>
/**
* 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