060.phpt 1.7 KB

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