fetch_object.phpt 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. --TEST--
  2. oci_fetch_object()
  3. --SKIPIF--
  4. <?php
  5. $target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs
  6. require(dirname(__FILE__).'/skipif.inc');
  7. ?>
  8. --FILE--
  9. <?php
  10. require(dirname(__FILE__).'/connect.inc');
  11. // Initialization
  12. $stmtarray = array(
  13. "drop table fetch_object_tab",
  14. "create table fetch_object_tab (\"caseSensitive\" number, secondcol varchar2(20), anothercol char(15))",
  15. "insert into fetch_object_tab values (123, '1st row col2 string', '1 more text')",
  16. "insert into fetch_object_tab values (456, '2nd row col2 string', '2 more text')",
  17. "insert into fetch_object_tab values (789, '3rd row col2 string', '3 more text')",
  18. );
  19. oci8_test_sql_execute($c, $stmtarray);
  20. // Run Test
  21. echo "Test 1\n";
  22. if (!($s = oci_parse($c, 'select * from fetch_object_tab'))) {
  23. die("oci_parse(select) failed!\n");
  24. }
  25. if (!oci_execute($s)) {
  26. die("oci_execute(select) failed!\n");
  27. }
  28. while ($row = oci_fetch_object($s)) {
  29. var_dump($row);
  30. }
  31. echo "Test 2\n";
  32. if (!($s = oci_parse($c, 'select * from fetch_object_tab'))) {
  33. die("oci_parse(select) failed!\n");
  34. }
  35. if (!oci_execute($s)) {
  36. die("oci_execute(select) failed!\n");
  37. }
  38. while ($row = oci_fetch_object($s)) {
  39. echo $row->caseSensitive . "\n";
  40. echo $row->SECONDCOL . "\n";
  41. echo $row->ANOTHERCOL . "\n";
  42. }
  43. echo "Test 3\n";
  44. if (!($s = oci_parse($c, 'select * from fetch_object_tab where rownum < 2 order by "caseSensitive"'))) {
  45. die("oci_parse(select) failed!\n");
  46. }
  47. if (!oci_execute($s)) {
  48. die("oci_execute(select) failed!\n");
  49. }
  50. $row = oci_fetch_object($s);
  51. echo $row->caseSensitive . "\n";
  52. echo $row->CASESENSITIVE . "\n";
  53. // Clean up
  54. $stmtarray = array(
  55. "drop table fetch_object_tab"
  56. );
  57. oci8_test_sql_execute($c, $stmtarray);
  58. ?>
  59. ===DONE===
  60. <?php exit(0); ?>
  61. --EXPECTF--
  62. Test 1
  63. object(stdClass)#1 (3) {
  64. ["caseSensitive"]=>
  65. string(3) "123"
  66. ["SECONDCOL"]=>
  67. string(19) "1st row col2 string"
  68. ["ANOTHERCOL"]=>
  69. string(15) "1 more text "
  70. }
  71. object(stdClass)#2 (3) {
  72. ["caseSensitive"]=>
  73. string(3) "456"
  74. ["SECONDCOL"]=>
  75. string(19) "2nd row col2 string"
  76. ["ANOTHERCOL"]=>
  77. string(15) "2 more text "
  78. }
  79. object(stdClass)#1 (3) {
  80. ["caseSensitive"]=>
  81. string(3) "789"
  82. ["SECONDCOL"]=>
  83. string(19) "3rd row col2 string"
  84. ["ANOTHERCOL"]=>
  85. string(15) "3 more text "
  86. }
  87. Test 2
  88. 123
  89. 1st row col2 string
  90. 1 more text
  91. 456
  92. 2nd row col2 string
  93. 2 more text
  94. 789
  95. 3rd row col2 string
  96. 3 more text
  97. Test 3
  98. 123
  99. Notice: Undefined property: stdClass::$CASESENSITIVE in %sfetch_object.php on line %d
  100. ===DONE===