ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:reference:connection:settransactionmode

setTransactionMode

See Also

metaTransaction()

Syntax
void setTransactionMode(
    string $mode
    )

Description

SetTransactionMode allows you to pass in the transaction mode to use for all subsequent transactions.

Note: if you have persistent connections and using mssql or mysql, you might have to explicitly reset your transaction mode at the beginning of each page request.

This is only supported in postgresql, mssql, mysql with InnoDB and oci8 currently.

Usage

/*
* Set the mode
*/
$db->setTransactionMode('serializable');
$db->beginTrans();
$db->execute(...); $db->execute(...);
$db->commitTrans();
 
/*
* restore to default
*/
$db->setTransactionMode(""); 
$db->startTrans();
$db->execute(...);
$db->execute(...);
$db->completeTrans();

Supported values to pass in:

  • READ UNCOMMITTED (allows dirty reads, but fastest)
  • READ COMMITTED (default postgres, mssql and oci8)
  • REPEATABLE READ (default mysql)
  • SERIALIZABLE (slowest and most restrictive)

You can also pass in database specific values such as 'SNAPSHOT' for mssql or 'READ ONLY' for oci8/postgres.

v5/reference/connection/settransactionmode.txt · Last modified: 2018/06/11 10:23 by dregad