June 2002
Intermediate to advanced
800 pages
16h 3m
English
Transactions and locks are strongly related to each other. After you have seen how locks can be treated, you can take a closer look at PHP and transactions. Usually working with transactions is an easy task. However, a closer look is necessary to find out what happens to uncommitted transactions. The next example shows what happens with transactions that are not committed manually:
<?php $dbh = pg_connect("host=localhost user=postgres dbname=phpbook"); if (!$dbh) { echo "error while connecting.<br>\n"; } execute("BEGIN;"); execute("INSERT INTO plant VALUES (6, 'cactus', 'green')"); function execute($sql) { global $dbh; $status = pg_exec($dbh, $sql); if (!$status) { echo "an error has occurred when executing ($sql)<br>\n"; ...Read now
Unlock full access