xref: /PHP-8.1/ext/pdo_mysql/tests/bug_33689.phpt (revision 39131219)
1--TEST--
2PDO MySQL Bug #33689 (query() execute() and fetch() return false on valid select queries)
3--EXTENSIONS--
4pdo
5pdo_mysql
6--SKIPIF--
7<?php
8require __DIR__ . '/config.inc';
9require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
10PDOTest::skip();
11?>
12--FILE--
13<?php
14require __DIR__ . '/config.inc';
15require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
16$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
17
18$db->exec('CREATE TABLE test (bar INT NOT NULL)');
19$db->exec('INSERT INTO test VALUES(1)');
20
21var_dump($db->query('SELECT * from test'));
22foreach ($db->query('SELECT * from test') as $row) {
23    print_r($row);
24}
25
26$stmt = $db->prepare('SELECT * from test');
27print_r($stmt->getColumnMeta(0));
28$stmt->execute();
29$tmp = $stmt->getColumnMeta(0);
30
31// libmysql and mysqlnd will show the pdo_type entry at a different position in the hash
32// and will report a different type, as mysqlnd returns native types.
33if (!isset($tmp['pdo_type']) || ($tmp['pdo_type'] != 1 && $tmp['pdo_type'] != 2))
34    printf("Expecting pdo_type = 1 got %s\n", $tmp['pdo_type']);
35else
36    unset($tmp['pdo_type']);
37
38print_r($tmp);
39?>
40--CLEAN--
41<?php
42require __DIR__ . '/mysql_pdo_test.inc';
43MySQLPDOTest::dropTestTable();
44?>
45--EXPECTF--
46object(PDOStatement)#%d (1) {
47  ["queryString"]=>
48  string(18) "SELECT * from test"
49}
50Array
51(
52    [bar] => 1
53    [0] => 1
54)
55Array
56(
57    [native_type] => LONG
58    [flags] => Array
59        (
60            [0] => not_null
61        )
62
63    [table] => test
64    [name] => bar
65    [len] => 11
66    [precision] => 0
67)
68