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