1--TEST-- 2MySQL PDO->prepare(), no warnings should be raised for binary values using emulated PS 3--EXTENSIONS-- 4pdo_mysql 5--SKIPIF-- 6<?php 7require_once __DIR__ . '/inc/mysql_pdo_test.inc'; 8MySQLPDOTest::skip(); 9?> 10--FILE-- 11<?php 12 require_once __DIR__ . '/inc/mysql_pdo_test.inc'; 13 $db = MySQLPDOTest::factory(); 14 $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); 15 16 // Force the connection to utf8, which is enough to make the test fail 17 // MySQL 5.6+ would be required for utf8mb4 18 $db->exec("SET NAMES 'utf8'"); 19 20 $content = '0191D886E6DC73E7AF1FEE7F99EC6235'; 21 22 $statement = $db->prepare('SELECT HEX(?) as test'); 23 $statement->bindValue(1, hex2bin($content), PDO::PARAM_LOB); 24 $statement->execute(); 25 26 var_dump($statement->fetchAll(PDO::FETCH_ASSOC)[0]['test'] === $content); 27 var_dump($db->query('SHOW WARNINGS')->fetchAll(PDO::FETCH_ASSOC)); 28 29 $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); 30 31 $statement2 = $db->prepare('SELECT HEX(?) as test'); 32 $statement2->bindValue(1, hex2bin($content), PDO::PARAM_LOB); 33 $statement2->execute(); 34 35 var_dump($statement2->fetchAll(PDO::FETCH_ASSOC)[0]['test'] === $content); 36 37 $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); // SHOW WARNINGS can only be used when PDO::ATTR_EMULATE_PREPARES=true 38 var_dump($db->query('SHOW WARNINGS')->fetchAll(PDO::FETCH_ASSOC)); 39 print "done!"; 40?> 41--EXPECTF-- 42bool(true) 43array(0) { 44} 45bool(true) 46array(0) { 47} 48done! 49