pq\Event::NOTICE
[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 new pq\Event($c, pq\Event::NOTICE, function($c, $notice) {
13 echo "Got notice: $notice";
14 });
15 $t = new pq\Transaction($c);
16 $c->exec("DROP TABLE IF EXISTS test; CREATE TABLE test (id serial, data text)");
17 $s = $c->prepare("test_insert", "INSERT INTO test (data) VALUES (\$1)", array($c->types->byName->text->oid));
18 $s->exec(array("a"));
19 $s->exec(array("b"));
20 $s->exec(array("c"));
21 $r = $c->exec("SELECT * FROM test");
22 while ($row = $r->fetchRow(pq\Result::FETCH_OBJECT)) {
23 printf("%d => %s\n", $row->id, $row->data);
24 }
25 $t->rollback();
26 ?>
27 DONE
28 --EXPECT--
29 Test
30 Got notice: NOTICE: table "test" does not exist, skipping
31 Got notice: NOTICE: CREATE TABLE will create implicit sequence "test_id_seq" for serial column "test.id"
32 1 => a
33 2 => b
34 3 => c
35 DONE