xref: /PHP-8.2/ext/pdo_mysql/tests/bug70862.phpt (revision 902d6439)
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 $context;
23        public function stream_open() { return true; }
24        public function stream_eof() { return true; }
25        public function stream_read() { return NULL; }
26        public function stream_stat() { return array(); }
27    }
28    stream_wrapper_register("hello", "HelloWrapper");
29
30    $f = fopen("hello://there", "r");
31
32    $stmt = $db->prepare('INSERT INTO test(id, label) VALUES (1, :para)');
33    $stmt->bindParam(":para", $f, PDO::PARAM_LOB);
34    $stmt->execute();
35
36    var_dump($f);
37
38    print "done!";
39?>
40--CLEAN--
41<?php
42require __DIR__ . '/mysql_pdo_test.inc';
43$db = MySQLPDOTest::factory();
44$db->exec('DROP TABLE IF EXISTS test');
45?>
46--EXPECT--
47string(0) ""
48done!
49