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