pq\Transaction docs
[mdref/mdref-pq] / pq / Transaction / __construct.md
1 # void pq\Transaction::__construct(pq\Connection $conn[, bool $async = FALSE[, int $isolation = pq\Transaction::READ_COMMITTED[, bool $readonly = FALSE[, bool $deferrable = FALSE]]]])
2
3 Start a transaction.
4 See pq\Connection::startTransaction().
5
6 ## Params:
7
8 * pq\Connection $conn
9 The connection to start the transaction on.
10 * Optional bool $async = FALSE
11 Whether to start the transaction [asynchronously](pq/Connection/: Asynchronous Usage).
12 * Optional int $isolation = pq\Transaction::READ_COMMITTED
13 The transaction isolation level (defaults to pq\Connection::$defaultTransactionIsolation).
14 * Optional bool $readonly = FALSE
15 Whether the transaction is readonly (defaults to pq\Connection::$defaultTransactionReadonly).
16 * Optional bool $deferrable = FALSE
17 Whether the transaction is deferrable (defaults to pq\Connection::$defaultTransactionDeferrable).
18
19 ## Throws:
20
21 * pq\Exception\InvalidArgumentException
22 * pq\Exception\BadMethodCallException
23 * pq\Exception\RuntimeException
24
25
26 ## Example:
27
28 <?php
29
30 $connection = new pq\Connection;
31 $transaction = new pq\Transaction(
32 $connection, FALSE, pq\Transaction::REPEATABLE_READ);
33
34 ?>