042.phpt 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. --TEST--
  2. mysqli_fetch_object
  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. mysqli_select_db($link, $db);
  15. mysqli_query($link, "SET sql_mode=''");
  16. mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
  17. mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 smallint unsigned,
  18. c2 smallint unsigned,
  19. c3 smallint,
  20. c4 smallint,
  21. c5 smallint,
  22. c6 smallint unsigned,
  23. c7 smallint) ENGINE=" . $engine);
  24. $stmt = mysqli_prepare($link, "INSERT INTO test_bind_fetch VALUES (?,?,?,?,?,?,?)");
  25. mysqli_stmt_bind_param($stmt, "iiiiiii", $c1,$c2,$c3,$c4,$c5,$c6,$c7);
  26. $c1 = -23;
  27. $c2 = 35999;
  28. $c3 = NULL;
  29. $c4 = -500;
  30. $c5 = -9999999;
  31. $c6 = -0;
  32. $c7 = 0;
  33. mysqli_stmt_execute($stmt);
  34. mysqli_stmt_close($stmt);
  35. $result = mysqli_query($link, "SELECT * FROM test_bind_fetch");
  36. $test = mysqli_fetch_object($result);
  37. mysqli_free_result($result);
  38. var_dump($test);
  39. mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch");
  40. mysqli_close($link);
  41. print "done!"
  42. ?>
  43. --CLEAN--
  44. <?php
  45. require_once("connect.inc");
  46. if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
  47. printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
  48. if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
  49. printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  50. mysqli_close($link);
  51. ?>
  52. --EXPECTF--
  53. object(stdClass)#%d (7) {
  54. ["c1"]=>
  55. string(1) "0"
  56. ["c2"]=>
  57. string(5) "35999"
  58. ["c3"]=>
  59. NULL
  60. ["c4"]=>
  61. string(4) "-500"
  62. ["c5"]=>
  63. string(6) "-32768"
  64. ["c6"]=>
  65. string(1) "0"
  66. ["c7"]=>
  67. string(1) "0"
  68. }
  69. done!