1--TEST--
2PDO_sqlite: Testing transaction
3--EXTENSIONS--
4pdo_sqlite
5--FILE--
6<?php
7
8$db = new PDO('sqlite::memory:');
9$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
10
11$db->beginTransaction();
12
13$db->query('CREATE TABLE IF NOT EXISTS foobar (id INT AUTO INCREMENT, name TEXT)');
14$db->commit();
15
16$db->beginTransaction();
17$db->query('INSERT INTO foobar VALUES (NULL, "PHP")');
18$db->query('INSERT INTO foobar VALUES (NULL, "PHP6")');
19$db->rollback();
20
21$r = $db->query('SELECT COUNT(*) FROM foobar');
22var_dump($r->rowCount());
23
24
25$db->query('DROP TABLE foobar');
26
27?>
28--EXPECTF--
29int(0)
30
31Warning: PDO::query(): SQLSTATE[HY000]: General error: 6 database table is locked in %s on line %d
32