xref: /PHP-8.1/ext/pdo_mysql/tests/bug70862.phpt (revision b5a14e6c)
1--TEST--
2MySQL Prepared Statements and BLOBs
3--EXTENSIONS--
4pdo_mysql
5--SKIPIF--
6<?php
7require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
8MySQLPDOTest::skip();
9?>
10--FILE--
11<?php
12    require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
13    $db = MySQLPDOTest::factory();
14
15    $db->exec('DROP TABLE IF EXISTS test');
16    $db->exec(sprintf('CREATE TABLE test(id INT, label BLOB)'));
17
18    $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0);
19    $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
20
21    class HelloWrapper {
22        public function stream_open() { return true; }
23        public function stream_eof() { return true; }
24        public function stream_read() { return NULL; }
25        public function stream_stat() { return array(); }
26    }
27    stream_wrapper_register("hello", "HelloWrapper");
28
29    $f = fopen("hello://there", "r");
30
31    $stmt = $db->prepare('INSERT INTO test(id, label) VALUES (1, :para)');
32    $stmt->bindParam(":para", $f, PDO::PARAM_LOB);
33    $stmt->execute();
34
35    var_dump($f);
36
37    print "done!";
38?>
39--CLEAN--
40<?php
41require __DIR__ . '/mysql_pdo_test.inc';
42$db = MySQLPDOTest::factory();
43$db->exec('DROP TABLE IF EXISTS test');
44?>
45--EXPECT--
46string(0) ""
47done!
48