fetch_object_2.phpt 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. --TEST--
  2. oci_fetch_object() with CLOB and NULL
  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_2_tab",
  14. "create table fetch_object_2_tab (col1 number, col2 CLOB, col3 varchar2(15))",
  15. "insert into fetch_object_2_tab values (123, '1st row col2 string', '1 more text')",
  16. "insert into fetch_object_2_tab values (456, '2nd row col2 string', NULL)",
  17. "insert into fetch_object_2_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_2_tab order by 1'))) {
  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_2_tab order by 1'))) {
  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->COL1 . "\n";
  40. echo $row->COL2->load(100) . "\n";
  41. echo $row->COL3 . "\n";
  42. }
  43. // Clean up
  44. $stmtarray = array(
  45. "drop table fetch_object_2_tab"
  46. );
  47. oci8_test_sql_execute($c, $stmtarray);
  48. ?>
  49. ===DONE===
  50. <?php exit(0); ?>
  51. --EXPECTF--
  52. Test 1
  53. object(stdClass)#%d (3) {
  54. ["COL1"]=>
  55. string(3) "123"
  56. ["COL2"]=>
  57. object(OCI-Lob)#%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(OCI-Lob)#%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(OCI-Lob)#%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
  95. ===DONE===