013.phpt 2.4 KB

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