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