042.phpt 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. --TEST--
  2. mysqli_fetch_object
  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. mysqli_select_db($link, $db);
  14. mysqli_query($link, "SET sql_mode=''");
  15. mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
  16. mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 smallint unsigned,
  17. c2 smallint unsigned,
  18. c3 smallint,
  19. c4 smallint,
  20. c5 smallint,
  21. c6 smallint unsigned,
  22. c7 smallint) ENGINE=" . $engine);
  23. $stmt = mysqli_prepare($link, "INSERT INTO test_bind_fetch VALUES (?,?,?,?,?,?,?)");
  24. mysqli_stmt_bind_param($stmt, "iiiiiii", $c1,$c2,$c3,$c4,$c5,$c6,$c7);
  25. $c1 = -23;
  26. $c2 = 35999;
  27. $c3 = NULL;
  28. $c4 = -500;
  29. $c5 = -9999999;
  30. $c6 = -0;
  31. $c7 = 0;
  32. mysqli_stmt_execute($stmt);
  33. mysqli_stmt_close($stmt);
  34. $result = mysqli_query($link, "SELECT * FROM test_bind_fetch");
  35. $test = mysqli_fetch_object($result);
  36. mysqli_free_result($result);
  37. var_dump($test);
  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. --EXPECTF--
  52. object(stdClass)#%d (7) {
  53. [%u|b%"c1"]=>
  54. %unicode|string%(1) "0"
  55. [%u|b%"c2"]=>
  56. %unicode|string%(5) "35999"
  57. [%u|b%"c3"]=>
  58. NULL
  59. [%u|b%"c4"]=>
  60. %unicode|string%(4) "-500"
  61. [%u|b%"c5"]=>
  62. %unicode|string%(6) "-32768"
  63. [%u|b%"c6"]=>
  64. %unicode|string%(1) "0"
  65. [%u|b%"c7"]=>
  66. %unicode|string%(1) "0"
  67. }
  68. done!