1--TEST--
2SQLite3::prepare Bound Variable Blob test
3--SKIPIF--
4<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
5--FILE--
6<?php
7
8require_once(dirname(__FILE__) . '/new_db.inc');
9require_once(dirname(__FILE__) . '/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 "Opening blob stream\n";
19$foo = fopen('sqliteBlobTest://fooo', 'r');
20var_dump($foo);
21
22echo "BINDING Parameter\n";
23var_dump($insert_stmt->bindValue(1, 'a', SQLITE3_TEXT));
24var_dump($insert_stmt->bindParam(2, $foo, SQLITE3_BLOB));
25$insert_stmt->execute();
26echo "Closing statement\n";
27var_dump($insert_stmt->close());
28
29echo "SELECTING results\n";
30$results = $db->query("SELECT id, quote(data) AS data FROM test ORDER BY id ASC");
31while ($result = $results->fetchArray(SQLITE3_NUM))
32{
33	var_dump($result);
34}
35$results->finalize();
36
37echo "Closing database\n";
38var_dump($db->close());
39echo "Done\n";
40?>
41--EXPECTF--
42Creating Table
43bool(true)
44PREPARING insert
45Opening blob stream
46resource(%d) of type (stream)
47BINDING Parameter
48bool(true)
49bool(true)
50Closing statement
51bool(true)
52SELECTING results
53array(2) {
54  [0]=>
55  string(1) "a"
56  [1]=>
57  string(23) "X'61626364656667006869'"
58}
59Closing database
60bool(true)
61Done
62