1--TEST-- 2mysqli_options() - MYSQLI_OPT_INT_AND_FLOAT_NATIVE 3--SKIPIF-- 4<?php 5require_once('skipif.inc'); 6require_once('skipifemb.inc'); 7require_once('skipifconnectfailure.inc'); 8 9require_once('connect.inc'); 10if (!$IS_MYSQLND) 11 die("skip mysqlnd only test"); 12?> 13--FILE-- 14<?php 15 require_once("connect.inc"); 16 17 18 $types = array( 19 'BIT' => array('BIT(8)', 0), 20 'TINYINT' => array('TINYINT', 120), 21 'BOOL' => array('BOOL', 0), 22 'BOOLEAN' => array('BOOLEAN', 1), 23 'SMALLINT' => array('SMALLINT', 32000), 24 'MEDIUMINT' => array('MEDIUMINT', 999), 25 'INT' => array('INT', 999), 26 'BIGINT' => array('BIGINT', 999), 27 'FLOAT' => array('FLOAT', 1.3), 28 'DOUBLE' => array('DOUBLE', -1.3), 29 ); 30 31 foreach ($types as $name => $data) { 32 $link = mysqli_init(); 33 if (!mysqli_options($link, MYSQLI_OPT_INT_AND_FLOAT_NATIVE, 1)) { 34 printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 35 continue; 36 } 37 38 if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) { 39 printf("[002] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); 40 continue; 41 } 42 43 44 if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) { 45 printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 46 continue; 47 } 48 49 if (!mysqli_query($link, sprintf("CREATE TABLE test (id %s)", $data[0]))) { 50 printf("[004] TODO [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 51 continue; 52 } 53 54 if (!mysqli_query($link, sprintf("INSERT INTO test(id) VALUES (%f)", $data[1]))) { 55 printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 56 continue; 57 } 58 59 if (!$res = mysqli_query($link, "SELECT id FROM test")) { 60 printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 61 continue; 62 } 63 64 $row = mysqli_fetch_assoc($res); 65 mysqli_free_result($res); 66 67 if ($row['id'] !== $data[1]) { 68 printf("[007] Expecting %s - %s/%s got %s/%s\n", 69 $name, 70 $data[1], gettype($data[1]), $row['id'], gettype($row['id'])); 71 } 72 mysqli_close($link); 73 74 $link = mysqli_init(); 75 if (!mysqli_options($link, MYSQLI_OPT_INT_AND_FLOAT_NATIVE, 0)) { 76 printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 77 continue; 78 } 79 80 if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) { 81 printf("[009] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); 82 continue; 83 } 84 85 if (!$res = mysqli_query($link, "SELECT id FROM test")) { 86 printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 87 continue; 88 } 89 90 $row = mysqli_fetch_assoc($res); 91 mysqli_free_result($res); 92 93 if (!is_string($row['id']) || ($row['id'] != $data[1])) { 94 printf("[011] Expecting %s - %s/string got %s/%s\n", 95 $name, 96 $data[1], $row['id'], gettype($row['id'])); 97 } 98 mysqli_close($link); 99 100 } 101 102 print "done!"; 103?> 104--CLEAN-- 105<?php 106 require_once("clean_table.inc"); 107?> 108--EXPECTF-- 109done!