1--TEST-- 2PDO MySQL specific class constants 3--SKIPIF-- 4<?php 5require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'skipif.inc'); 6?> 7--FILE-- 8<?php 9 require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); 10 11 $expected = array( 12 'MYSQL_ATTR_USE_BUFFERED_QUERY' => true, 13 'MYSQL_ATTR_LOCAL_INFILE' => true, 14 'MYSQL_ATTR_DIRECT_QUERY' => true, 15 'MYSQL_ATTR_FOUND_ROWS' => true, 16 'MYSQL_ATTR_IGNORE_SPACE' => true, 17 'MYSQL_ATTR_INIT_COMMAND' => true, 18 "MYSQL_ATTR_SSL_KEY" => true, 19 "MYSQL_ATTR_SSL_CERT" => true, 20 "MYSQL_ATTR_SSL_CA" => true, 21 "MYSQL_ATTR_SSL_CAPATH" => true, 22 "MYSQL_ATTR_SSL_CIPHER" => true, 23 "MYSQL_ATTR_COMPRESS" => true, 24 ); 25 26 if (!MySQLPDOTest::isPDOMySQLnd()) { 27 $expected['MYSQL_ATTR_MAX_BUFFER_SIZE'] = true; 28 $expected['MYSQL_ATTR_READ_DEFAULT_FILE'] = true; 29 $expected['MYSQL_ATTR_READ_DEFAULT_GROUP'] = true; 30 } 31 32 /* 33 TODO 34 35 MYSQLI_OPT_CONNECT_TIMEOUT != PDO::ATTR_TIMEOUT (integer) 36 Sets the timeout value in seconds for communications with the database. 37 ^ Potential BUG, PDO::ATTR_TIMEOUT is used in pdo_mysql_handle_factory 38 39 MYSQLI_SET_CHARSET_NAME -> DSN/charset=<charset_name> 40 ^ Undocumented and pitfall for ext/mysqli users 41 42 Assorted mysqlnd settings missing 43 */ 44 $ref = new ReflectionClass('PDO'); 45 $constants = $ref->getConstants(); 46 $values = array(); 47 48 foreach ($constants as $name => $value) 49 if (substr($name, 0, 11) == 'MYSQL_ATTR_') { 50 if (!isset($values[$value])) 51 $values[$value] = array($name); 52 else 53 $values[$value][] = $name; 54 55 if (isset($expected[$name])) { 56 unset($expected[$name]); 57 unset($constants[$name]); 58 } 59 60 } else { 61 unset($constants[$name]); 62 } 63 64 if (!empty($constants)) { 65 printf("[001] Dumping list of unexpected constants\n"); 66 var_dump($constants); 67 } 68 69 if (!empty($expected)) { 70 printf("[002] Dumping list of missing constants\n"); 71 var_dump($expected); 72 } 73 74 if (!empty($values)) { 75 foreach ($values as $value => $constants) { 76 if (count($constants) > 1) { 77 printf("[003] Several constants share the same value '%s'\n", $value); 78 var_dump($constants); 79 } 80 } 81 } 82 83 print "done!"; 84--EXPECT-- 85done! 86