1--TEST-- 2SQLite3::backup test 3--EXTENSIONS-- 4sqlite3 5--FILE-- 6<?php 7 8require_once(__DIR__ . '/new_db.inc'); 9 10echo "Creating table\n"; 11$db->exec('CREATE TABLE test (a, b);'); 12$db->exec('INSERT INTO test VALUES (42, \'php\');'); 13 14echo "Checking if table has been created\n"; 15var_dump($db->querySingle('SELECT COUNT(*) FROM sqlite_master;')); 16 17$db2 = new SQLite3(':memory:'); 18 19echo "Backup to DB2\n"; 20var_dump($db->backup($db2)); 21 22echo "Checking if table has been copied\n"; 23var_dump($db2->querySingle('SELECT COUNT(*) FROM sqlite_master;')); 24 25echo "Checking backup contents\n"; 26var_dump($db2->querySingle('SELECT a FROM test;')); 27var_dump($db2->querySingle('SELECT b FROM test;')); 28 29echo "Resetting DB2\n"; 30 31$db2->close(); 32$db2 = new SQLite3(':memory:'); 33 34echo "Locking DB1\n"; 35var_dump($db->exec('BEGIN EXCLUSIVE;')); 36 37echo "Backup to DB2 (should fail)\n"; 38var_dump($db->backup($db2)); 39 40?> 41--EXPECTF-- 42Creating table 43Checking if table has been created 44int(1) 45Backup to DB2 46bool(true) 47Checking if table has been copied 48int(1) 49Checking backup contents 50int(42) 51string(3) "php" 52Resetting DB2 53Locking DB1 54bool(true) 55Backup to DB2 (should fail) 56 57Warning: SQLite3::backup(): Backup failed: source database is busy in %s on line %d 58bool(false)