fetch_object_2.phpt 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. --TEST--
  2. oci_fetch_object() with CLOB and NULL
  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_2_tab",
  16. "create table fetch_object_2_tab (col1 number, col2 CLOB, col3 varchar2(15))",
  17. "insert into fetch_object_2_tab values (123, '1st row col2 string', '1 more text')",
  18. "insert into fetch_object_2_tab values (456, '2nd row col2 string', NULL)",
  19. "insert into fetch_object_2_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_2_tab order by 1'))) {
  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_2_tab order by 1'))) {
  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->COL1 . "\n";
  42. echo $row->COL2->load() . "\n";
  43. echo $row->COL3 . "\n";
  44. }
  45. // Clean up
  46. $stmtarray = array(
  47. "drop table fetch_object_2_tab"
  48. );
  49. oci8_test_sql_execute($c, $stmtarray);
  50. ?>
  51. --EXPECTF--
  52. Test 1
  53. object(stdClass)#%d (3) {
  54. ["COL1"]=>
  55. string(3) "123"
  56. ["COL2"]=>
  57. object(OCILob)#%d (1) {
  58. ["descriptor"]=>
  59. resource(%d) of type (oci8 descriptor)
  60. }
  61. ["COL3"]=>
  62. string(11) "1 more text"
  63. }
  64. object(stdClass)#%d (3) {
  65. ["COL1"]=>
  66. string(3) "456"
  67. ["COL2"]=>
  68. object(OCILob)#%d (1) {
  69. ["descriptor"]=>
  70. resource(%d) of type (oci8 descriptor)
  71. }
  72. ["COL3"]=>
  73. NULL
  74. }
  75. object(stdClass)#%d (3) {
  76. ["COL1"]=>
  77. string(3) "789"
  78. ["COL2"]=>
  79. object(OCILob)#%d (1) {
  80. ["descriptor"]=>
  81. resource(%d) of type (oci8 descriptor)
  82. }
  83. ["COL3"]=>
  84. string(11) "3 more text"
  85. }
  86. Test 2
  87. 123
  88. 1st row col2 string
  89. 1 more text
  90. 456
  91. 2nd row col2 string
  92. 789
  93. 3rd row col2 string
  94. 3 more text