060.phpt 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. --TEST--
  2. mysqli_fetch_object with classes
  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. class test_class {
  12. function __construct($arg1, $arg2) {
  13. echo __METHOD__ . "($arg1,$arg2)\n";
  14. }
  15. }
  16. /*** test mysqli_connect 127.0.0.1 ***/
  17. $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
  18. mysqli_select_db($link, $db);
  19. mysqli_query($link, "SET sql_mode=''");
  20. mysqli_query($link,"DROP TABLE IF EXISTS test_fetch");
  21. mysqli_query($link,"CREATE TABLE test_fetch(c1 smallint unsigned,
  22. c2 smallint unsigned,
  23. c3 smallint,
  24. c4 smallint,
  25. c5 smallint,
  26. c6 smallint unsigned,
  27. c7 smallint)");
  28. mysqli_query($link, "INSERT INTO test_fetch VALUES ( -23, 35999, NULL, -500, -9999999, -0, 0)");
  29. $result = mysqli_query($link, "SELECT * FROM test_fetch");
  30. $test = mysqli_fetch_object($result, 'test_class', array(1, 2));
  31. mysqli_free_result($result);
  32. var_dump($test);
  33. mysqli_close($link);
  34. echo "Done\n";
  35. ?>
  36. --CLEAN--
  37. <?php
  38. require_once("connect.inc");
  39. if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
  40. printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
  41. if (!mysqli_query($link, "DROP TABLE IF EXISTS test_fetch"))
  42. printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  43. mysqli_close($link);
  44. ?>
  45. --EXPECTF--
  46. test_class::__construct(1,2)
  47. object(test_class)#%d (7) {
  48. [%u|b%"c1"]=>
  49. %unicode|string%(1) "0"
  50. [%u|b%"c2"]=>
  51. %unicode|string%(5) "35999"
  52. [%u|b%"c3"]=>
  53. NULL
  54. [%u|b%"c4"]=>
  55. %unicode|string%(4) "-500"
  56. [%u|b%"c5"]=>
  57. %unicode|string%(6) "-32768"
  58. [%u|b%"c6"]=>
  59. %unicode|string%(1) "0"
  60. [%u|b%"c7"]=>
  61. %unicode|string%(1) "0"
  62. }
  63. Done