The main generated code sections are:
Defining the transaction
connection. This object is used to create a database
independence layer for Transaction Engine 3 Lite:
$conn_test = new tNG_connection($test, $database_test);
Defining the transaction dispatcher:
$tNGs = new tNG_dispatcher("");
Create a transaction instance
$insertTNG1 = new tNG_insert($conn_test);
Add the
created transaction to the dispatcher:
$tNGs->addTransaction($insertTNG1);
Register triggers
(STARTER and END - Redirect):
$insertTNG1->registerTrigger("STARTER", "Trigger_Default_Starter",
1, "POST", "MM_Insert");
$insertTNG1->registerTrigger("END", "Trigger_Default_Redirect",
99, "index.php");
Set the appropriate table
to the transaction:
$insertTNG1->setTable("departments_dep");
Add all selected columns
with all specified parameters
(name, type, method, reference, default value):
$insertTNG1->addColumn("id_dep", "NUMERIC_TYPE",
"POST", "id", "1");
$insertTNG1->addColumn("name_dep", "STRING_TYPE",
"POST", "name");
For each column specified in the Columns grid in the Server Behavior
interface, one addColumn() function call will exist.
addColumn(DB_FIELD_NAME, DB_TYPE, METHOD, REFERENCE, DEFAULT_VALUE);
Set the primary
key:
If the transaction is of Insert, Update or Delete type, the primary key
and its type will have to be specified. The Custom Transaction and other
transactions that will be developed in the future, do not require a primary
key to be defined
$insertTNG1->setPrimaryKey("id_dep", "NUMERIC_TYPE");
Execute
the transaction:
$tNGs->executeTransactions();
Get the Transaction
Recordset. The dispatcher will search all registered transactions that
are linked to the given table and will return the correct Recordset.
// Get the transaction recordset
$rsDepartments_dep = $tNGs->getRecordset("departments_dep");
$row_rsDepartments_dep = mysql_fetch_assoc($rsDepartments_dep );
$totalRows_rsDepartments_dep = mysql_num_rows($rsDepartments_dep );