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