1
0
mirror of https://github.com/danog/ext-pq.git synced 2024-12-02 17:28:35 +01:00
ext-pq/tests/trans001.phpt

36 lines
903 B
Plaintext
Raw Normal View History

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-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-01-26 19:57:07 +01:00
$c->exec("DROP TABLE IF EXISTS test; CREATE TABLE test (id serial, data text)");
$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