2013-01-25 21:08:56 +01:00
|
|
|
--TEST--
|
|
|
|
transaction
|
|
|
|
--SKIPIF--
|
|
|
|
<?php include "_skipif.inc"; ?>
|
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
echo "Test\n";
|
|
|
|
|
|
|
|
include "_setup.inc";
|
|
|
|
|
|
|
|
$c = new pq\Connection(PQ_DSN);
|
2013-02-05 22:00:06 +01:00
|
|
|
$c->exec("DROP TABLE IF EXISTS test");
|
2013-01-26 19:57:07 +01:00
|
|
|
new pq\Event($c, pq\Event::NOTICE, function($c, $notice) {
|
2013-01-30 17:21:38 +01:00
|
|
|
echo "Got notice: $notice\n";
|
2013-01-26 19:57:07 +01:00
|
|
|
});
|
2013-01-25 21:08:56 +01:00
|
|
|
$t = new pq\Transaction($c);
|
2013-02-05 22:00:06 +01:00
|
|
|
$c->exec("DROP TABLE IF EXISTS test");
|
|
|
|
$c->exec("CREATE TABLE test (id serial, data text)");
|
2013-01-29 21:02:25 +01:00
|
|
|
$s = $c->prepare("test_insert", "INSERT INTO test (data) VALUES (\$1)", array((new pq\Types($c))["text"]->oid));
|
2013-01-25 21:08:56 +01:00
|
|
|
$s->exec(array("a"));
|
|
|
|
$s->exec(array("b"));
|
|
|
|
$s->exec(array("c"));
|
|
|
|
$r = $c->exec("SELECT * FROM test");
|
|
|
|
while ($row = $r->fetchRow(pq\Result::FETCH_OBJECT)) {
|
|
|
|
printf("%d => %s\n", $row->id, $row->data);
|
|
|
|
}
|
|
|
|
$t->rollback();
|
|
|
|
?>
|
|
|
|
DONE
|
|
|
|
--EXPECT--
|
|
|
|
Test
|
2013-01-26 19:57:07 +01:00
|
|
|
Got notice: NOTICE: table "test" does not exist, skipping
|
|
|
|
Got notice: NOTICE: CREATE TABLE will create implicit sequence "test_id_seq" for serial column "test.id"
|
2013-01-25 21:08:56 +01:00
|
|
|
1 => a
|
|
|
|
2 => b
|
|
|
|
3 => c
|
|
|
|
DONE
|