1--TEST-- 2SQLite3::blobOpen stream test 3--SKIPIF-- 4<?php require_once(__DIR__ . '/skipif.inc'); ?> 5--FILE-- 6<?php 7 8require_once(__DIR__ . '/new_db.inc'); 9require_once(__DIR__ . '/stream_test.inc'); 10define('TIMENOW', time()); 11 12echo "Creating Table\n"; 13var_dump($db->exec('CREATE TABLE test (id STRING, data BLOB)')); 14 15echo "PREPARING insert\n"; 16$insert_stmt = $db->prepare("INSERT INTO test (id, data) VALUES (?, ?)"); 17 18echo "BINDING Parameter\n"; 19var_dump($insert_stmt->bindValue(1, 'a', SQLITE3_TEXT)); 20var_dump($insert_stmt->bindValue(2, 'TEST TEST', SQLITE3_BLOB)); 21$insert_stmt->execute(); 22echo "Closing statement\n"; 23var_dump($insert_stmt->close()); 24$stream = $db->openBlob('test', 'data', 1); 25var_dump($stream); 26echo "Stream Contents\n"; 27var_dump(stream_get_contents($stream)); 28echo "Writing to read-only stream\n"; 29var_dump(fwrite($stream, 'ABCD')); 30echo "Closing Stream\n"; 31var_dump(fclose($stream)); 32echo "Opening stream in write mode\n"; 33$stream = $db->openBlob('test', 'data', 1, 'main', SQLITE3_OPEN_READWRITE); 34var_dump($stream); 35echo "Writing to blob\n"; 36var_dump(fwrite($stream, 'ABCD')); 37echo "Stream Contents\n"; 38fseek($stream, 0); 39var_dump(stream_get_contents($stream)); 40echo "Expanding blob size\n"; 41var_dump(fwrite($stream, 'ABCD ABCD ABCD')); 42echo "Closing Stream\n"; 43var_dump(fclose($stream)); 44echo "Closing database\n"; 45var_dump($db->close()); 46echo "Done\n"; 47?> 48--EXPECTF-- 49Creating Table 50bool(true) 51PREPARING insert 52BINDING Parameter 53bool(true) 54bool(true) 55Closing statement 56bool(true) 57resource(%d) of type (stream) 58Stream Contents 59string(9) "TEST TEST" 60Writing to read-only stream 61 62Warning: fwrite(): Can't write to blob stream: is open as read only in %s on line %d 63int(0) 64Closing Stream 65bool(true) 66Opening stream in write mode 67resource(%d) of type (stream) 68Writing to blob 69int(4) 70Stream Contents 71string(9) "ABCD TEST" 72Expanding blob size 73 74Warning: fwrite(): It is not possible to increase the size of a BLOB in %s on line %d 75int(0) 76Closing Stream 77bool(true) 78Closing database 79bool(true) 80Done 81