010.phpt 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. --TEST--
  2. mysqli fetch float values
  3. --INI--
  4. precision=12
  5. --EXTENSIONS--
  6. mysqli
  7. --SKIPIF--
  8. <?php
  9. require_once('skipifconnectfailure.inc');
  10. ?>
  11. --FILE--
  12. <?php
  13. require_once("connect.inc");
  14. /*** test mysqli_connect 127.0.0.1 ***/
  15. $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
  16. if (!mysqli_query($link, "SET sql_mode=''"))
  17. printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  18. if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
  19. printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  20. $rc = mysqli_query($link, "CREATE TABLE test_bind_fetch(c1 float(3),
  21. c2 float,
  22. c3 float unsigned,
  23. c4 float,
  24. c5 float,
  25. c6 float,
  26. c7 float(10) unsigned) ENGINE=" . $engine);
  27. if (!$rc)
  28. printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  29. mysqli_query($link, "INSERT INTO test_bind_fetch (c1,c2,c3,c4,c5,c6,c7) VALUES (3.1415926535,-0.000001, -5, 999999999999,
  30. sin(0.6), 1.00000000000001, 888888888888888)");
  31. $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
  32. mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
  33. mysqli_stmt_execute($stmt);
  34. mysqli_stmt_fetch($stmt);
  35. $test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
  36. var_dump($test);
  37. mysqli_stmt_close($stmt);
  38. mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch");
  39. mysqli_close($link);
  40. print "done!";
  41. ?>
  42. --CLEAN--
  43. <?php
  44. require_once("connect.inc");
  45. if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
  46. printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
  47. if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
  48. printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  49. mysqli_close($link);
  50. ?>
  51. --EXPECT--
  52. array(7) {
  53. [0]=>
  54. float(3.14159)
  55. [1]=>
  56. float(-1.0E-6)
  57. [2]=>
  58. float(0)
  59. [3]=>
  60. float(1000000000000)
  61. [4]=>
  62. float(0.564642)
  63. [5]=>
  64. float(1)
  65. [6]=>
  66. float(888889000000000)
  67. }
  68. done!