013.phpt 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. --TEST--
  2. mysqli fetch mixed / mysql_query (may fail when using 4.1 library with 5.x server)
  3. --SKIPIF--
  4. <?php
  5. require_once('skipif.inc');
  6. require_once('skipifconnectfailure.inc');
  7. ?>
  8. --FILE--
  9. <?php
  10. require_once("connect.inc");
  11. /*** test mysqli_connect 127.0.0.1 ***/
  12. $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
  13. if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result"))
  14. printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  15. $rc = mysqli_query($link, "CREATE TABLE test_bind_result(c1 tinyint, c2 smallint,
  16. c3 int, c4 bigint,
  17. c5 decimal(4,2), c6 double,
  18. c7 varbinary(10),
  19. c8 varchar(10)) ENGINE=" . $engine);
  20. if (!$rc)
  21. printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  22. if (!mysqli_query($link, "INSERT INTO test_bind_result VALUES(120,2999,3999,54,
  23. 2.6,58.89,
  24. '206','6.7')"))
  25. printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  26. $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_result");
  27. $c = array(0,0,0,0,0,0,0,0);
  28. $b_res= mysqli_stmt_bind_result($stmt, $c[0], $c[1], $c[2], $c[3], $c[4], $c[5], $c[6], $c[7]);
  29. mysqli_stmt_execute($stmt);
  30. mysqli_stmt_fetch($stmt);
  31. mysqli_stmt_fetch($stmt);
  32. mysqli_stmt_close($stmt);
  33. $result = mysqli_query($link, "select * from test_bind_result");
  34. $d = mysqli_fetch_row($result);
  35. mysqli_free_result($result);
  36. $test = "";
  37. for ($i=0; $i < count($c); $i++)
  38. $test .= ($c[$i] == $d[$i]) ? "1" : "0";
  39. if ($test == "11111111")
  40. echo "ok\n";
  41. else if ($b_res == FALSE && mysqli_get_client_version() > 40100 && mysqli_get_client_version() < 50000 &&
  42. mysqli_get_server_version($link) > 50000)
  43. echo "error (4.1 library with 5.x server)";
  44. else
  45. echo "error";
  46. mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result");
  47. mysqli_close($link);
  48. print "done!";
  49. ?>
  50. --CLEAN--
  51. <?php
  52. require_once("connect.inc");
  53. if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
  54. printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
  55. if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result"))
  56. printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  57. mysqli_close($link);
  58. ?>
  59. --EXPECTF--
  60. ok
  61. done!