xref: /PHP-8.0/ext/mysqli/tests/bug75018.phpt (revision e3e67b72)
1--TEST--
2Bug #75018 Data corruption when reading fields of bit type
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6require_once('skipifconnectfailure.inc');
7?>
8--FILE--
9<?php
10require_once("connect.inc");
11
12$mysqli = new mysqli("$host:$port", $user, $passwd, $db);
13
14$tbl = "test_bug75018";
15$sql = "DROP TABLE IF EXISTS $tbl";
16$mysqli->query($sql);
17
18$sql = "CREATE TABLE $tbl (bit_column_1 bit(16) NOT NULL) DEFAULT CHARSET=utf8";
19$mysqli->query($sql);
20
21$sql = "INSERT INTO $tbl (bit_column_1) VALUES (0)";
22$mysqli->query($sql);
23$sql = "INSERT INTO $tbl (bit_column_1) VALUES (0b10101010101)";
24$mysqli->query($sql);
25
26$sql = "SELECT bit_column_1 FROM $tbl";
27$result = $mysqli->query($sql);
28
29while ($row = $result->fetch_assoc()) {
30    var_dump($row['bit_column_1']);
31}
32
33?>
34--EXPECT--
35string(1) "0"
36string(4) "1365"
37