1--TEST--
2MySQL PDO->exec(), BIT columns - remove after fix!
3--EXTENSIONS--
4pdo_mysql
5--SKIPIF--
6<?php
7require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
8MySQLPDOTest::skip();
9if (MySQLPDOTest::isPDOMySQLnd())
10    die("skip Known bug - mysqlnd handles BIT incorrectly!");
11?>
12--FILE--
13<?php
14    /* TODO: remove this test after fix and enable the BIT test in pdo_mysql_types.phpt again */
15    require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
16
17    function test_type(&$db, $offset, $sql_type, $value, $ret_value = NULL, $pattern = NULL) {
18
19        $db->exec('DROP TABLE IF EXISTS test');
20        $sql = sprintf('CREATE TABLE test(id INT, label %s) ENGINE=%s', $sql_type, MySQLPDOTest::getTableEngine());
21        @$db->exec($sql);
22        if ($db->errorCode() != 0) {
23            // not all MySQL Server versions and/or engines might support the type
24            return true;
25        }
26
27        $stmt = $db->prepare('INSERT INTO test(id, label) VALUES (?, ?)');
28        $stmt->bindValue(1, $offset);
29        $stmt->bindValue(2, $value);
30        if (!$stmt->execute()) {
31            printf("[%03d + 1] INSERT failed, %s\n", $offset, var_export($stmt->errorInfo(), true));
32            return false;
33        }
34        $stmt = $db->query('SELECT  id, label FROM test');
35        $row = $stmt->fetch(PDO::FETCH_ASSOC);
36        var_dump($row);
37        var_dump($value);
38
39        return true;
40    }
41
42    $db = MySQLPDOTest::factory();
43    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
44    $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
45    $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
46
47    test_type($db, 20, 'BIT(8)', 1);
48
49    echo "done!\n";
50?>
51--CLEAN--
52<?php
53require __DIR__ . '/mysql_pdo_test.inc';
54$db = MySQLPDOTest::factory();
55$db->exec('DROP TABLE IF EXISTS test');
56?>
57--EXPECT--
58array(2) {
59  ["id"]=>
60  string(2) "20"
61  ["label"]=>
62  string(1) "1"
63}
64int(1)
65done!
66