Icon edb_starttrans

Starts a transaction on one or more tables in the current database.

Syntax
edb_starttrans(<ConnectionHandle> [, <TableNames>])

<ConnectionHandle> =

Handle of connection returned by edb_connect function

<TableNames> = A single table name (STRING), or an
array of table names for multiple tables

Returns
TRUE if successful, or FALSE if there are any errors

Usage
The edb_starttrans function starts a transaction on one or more tables in the current database. You can specify the tables that you want to be involved in the transaction as a single string for one table or an array of strings for multiple tables. If you do not specify the table names, then the transaction will cover all tables in the current database.

Please see the Transactions topic in the SQL manual for more information on how transactions work in ElevateDB.

Examples
<?php

// The following script connects to an ElevateDB
// Server and database, starts a transaction on
// the Customer and Orders tables using the
// edb_starttrans() function, inserts a row
// into each table, commits the transaction
// using the edb_commit() function, and then
// disconnects using the edb_disconnect() function

$con = edb_connect("type=remote;charset=Ansi;address=127.0.0.1;"+
                   "uid=Administrator;pwd=EDBDefault;database=Test");
if (!$con)
  {
  die("Could not connect: " . edb_errmsg());
  }

edb_starttrans($con,array("Customer","Orders"));

echo edb_intrans($con);

$custcmd = edb_prepare($con,"customer",EDB_COMMAND_TABLE);
$custcursor = edb_execute($custcmd);

$ordcmd = edb_prepare($con,"orders",EDB_COMMAND_TABLE);
$ordcursor = edb_execute($ordcmd);

edb_insert($custcursor);
edb_setcol($custcursor,"CustNo",1000);
edb_setcol($custcursor,"Company","Test Company");
if (!edb_post($custcursor))
  {
  $msg = edb_errmsg();
  edb_rollback($con);
  die("Error adding customer: " . $msg);
  }

edb_insert($ordcursor);
edb_setcol($ordcursor,"CustNo",1000);
edb_setcol($ordcursor,"OrderNo",100);
edb_setcol($ordcursor,"SaleDate","2010-02-24");
edb_setcol($ordcursor,"EmpNo",10);
if (!edb_post($ordcursor))
  {
  $msg = edb_errmsg();
  edb_rollback($con);
  die("Error adding order: " . $msg);
  }

edb_commit($con);

edb_disconnect($con);
?>
Image