cancel
[m6w6/ext-pq] / tests / trans001.phpt
1 --TEST--
2 transaction
3 --SKIPIF--
4 <?php include "_skipif.inc"; ?>
5 --FILE--
6 <?php
7 echo "Test\n";
8
9 include "_setup.inc";
10
11 $c = new pq\Connection(PQ_DSN);
12 $t = new pq\Transaction($c);
13 $c->exec("CREATE TABLE test (id serial, data text)");
14 $s = $c->prepare("test_insert", "INSERT INTO test (data) VALUES (\$1)", array($c->types->byName->text->oid));
15 $s->exec(array("a"));
16 $s->exec(array("b"));
17 $s->exec(array("c"));
18 $r = $c->exec("SELECT * FROM test");
19 while ($row = $r->fetchRow(pq\Result::FETCH_OBJECT)) {
20 printf("%d => %s\n", $row->id, $row->data);
21 }
22 $t->rollback();
23 ?>
24 DONE
25 --EXPECT--
26 Test
27 1 => a
28 2 => b
29 3 => c
30 DONE