xref: /PHP-8.2/ext/pdo_mysql/tests/bug75177.phpt (revision b5a14e6c)
1--TEST--
2PDO MySQL Bug #75177 Type 'bit' is fetched as unexpected string
3--EXTENSIONS--
4pdo_mysql
5--SKIPIF--
6<?php
7require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
8MySQLPDOTest::skip();
9if (!MySQLPDOTest::isPDOMySQLnd()) die('skip only for mysqlnd');
10?>
11--FILE--
12<?php
13require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
14$pdo = MySQLPDOTest::factory();
15
16$tbl = "test";
17$pdo->query("DROP TABLE IF EXISTS $tbl");
18$pdo->query("CREATE TABLE $tbl (`bit` bit(8)) ENGINE=InnoDB");
19$pdo->query("INSERT INTO $tbl (`bit`) VALUES (1)");
20$pdo->query("INSERT INTO $tbl (`bit`) VALUES (0b011)");
21$pdo->query("INSERT INTO $tbl (`bit`) VALUES (0b01100)");
22
23$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
24$ret = $pdo->query("SELECT * FROM $tbl")->fetchAll();
25foreach ($ret as $i) {
26    var_dump($i["bit"]);
27}
28
29$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
30$ret = $pdo->query("SELECT * FROM $tbl")->fetchAll();
31foreach ($ret as $i) {
32    var_dump($i["bit"]);
33}
34
35?>
36--CLEAN--
37<?php
38require dirname(__FILE__) . '/mysql_pdo_test.inc';
39MySQLPDOTest::dropTestTable();
40?>
41--EXPECT--
42int(1)
43int(3)
44int(12)
45int(1)
46int(3)
47int(12)
48