1--TEST-- 2mysqli_float_handling - ensure 4 byte float is handled correctly 3--SKIPIF-- 4<?php 5 require_once('skipif.inc'); 6 require_once('skipifemb.inc'); 7 require_once('skipifconnectfailure.inc'); 8?> 9--FILE-- 10<?php 11 require('connect.inc'); 12 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { 13 printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); 14 die(); 15 } 16 17 18 if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) { 19 printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 20 die(); 21 } 22 23 if (!mysqli_query($link, "CREATE TABLE test(id INT PRIMARY KEY, fp4 FLOAT, fp8 DOUBLE) ENGINE = InnoDB")) { 24 printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 25 die(); 26 } 27 28 // Insert via string to make sure the real floating number gets to the DB 29 if (!mysqli_query($link, "INSERT INTO test(id, fp4, fp8) VALUES (1, 9.9999, 9.9999)")) { 30 printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 31 die(); 32 } 33 34 if (!($stmt = mysqli_prepare($link, "SELECT id, fp4, fp8 FROM test"))) { 35 printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 36 die(); 37 } 38 39 if (!mysqli_stmt_execute($stmt)) { 40 printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 41 die(); 42 } 43 44 45 if (!($result = mysqli_stmt_get_result($stmt))) { 46 printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 47 die(); 48 } 49 50 $data = mysqli_fetch_assoc($result); 51 print $data['id'] . ": " . $data['fp4'] . ": " . $data['fp8'] . "\n"; 52?> 53--CLEAN-- 54<?php 55 require_once("clean_table.inc"); 56?> 57--EXPECTF-- 581: 9.9999: 9.9999 59