fetch_object_1.phpt 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. --TEST--
  2. oci_fetch_object()
  3. --EXTENSIONS--
  4. oci8
  5. --SKIPIF--
  6. <?php
  7. $target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs
  8. require(__DIR__.'/skipif.inc');
  9. ?>
  10. --FILE--
  11. <?php
  12. require(__DIR__.'/connect.inc');
  13. // Initialization
  14. $stmtarray = array(
  15. "drop table fetch_object_tab",
  16. "create table fetch_object_tab (\"caseSensitive\" number, secondcol varchar2(20), anothercol char(15))",
  17. "insert into fetch_object_tab values (123, '1st row col2 string', '1 more text')",
  18. "insert into fetch_object_tab values (456, '2nd row col2 string', '2 more text')",
  19. "insert into fetch_object_tab values (789, '3rd row col2 string', '3 more text')",
  20. );
  21. oci8_test_sql_execute($c, $stmtarray);
  22. // Run Test
  23. echo "Test 1\n";
  24. if (!($s = oci_parse($c, 'select * from fetch_object_tab'))) {
  25. die("oci_parse(select) failed!\n");
  26. }
  27. if (!oci_execute($s)) {
  28. die("oci_execute(select) failed!\n");
  29. }
  30. while ($row = oci_fetch_object($s)) {
  31. var_dump($row);
  32. }
  33. echo "Test 2\n";
  34. if (!($s = oci_parse($c, 'select * from fetch_object_tab'))) {
  35. die("oci_parse(select) failed!\n");
  36. }
  37. if (!oci_execute($s)) {
  38. die("oci_execute(select) failed!\n");
  39. }
  40. while ($row = oci_fetch_object($s)) {
  41. echo $row->caseSensitive . "\n";
  42. echo $row->SECONDCOL . "\n";
  43. echo $row->ANOTHERCOL . "\n";
  44. }
  45. echo "Test 3\n";
  46. if (!($s = oci_parse($c, 'select * from fetch_object_tab where rownum < 2 order by "caseSensitive"'))) {
  47. die("oci_parse(select) failed!\n");
  48. }
  49. if (!oci_execute($s)) {
  50. die("oci_execute(select) failed!\n");
  51. }
  52. $row = oci_fetch_object($s);
  53. echo $row->caseSensitive . "\n";
  54. echo $row->CASESENSITIVE . "\n";
  55. // Clean up
  56. $stmtarray = array(
  57. "drop table fetch_object_tab"
  58. );
  59. oci8_test_sql_execute($c, $stmtarray);
  60. ?>
  61. --EXPECTF--
  62. Test 1
  63. object(stdClass)#%d (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)#%d (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)#%d (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. Warning: Undefined property: stdClass::$CASESENSITIVE in %sfetch_object_1.php on line %d