lob_037.phpt 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. --TEST--
  2. Fetching two different lobs and using them after fetch
  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. require __DIR__.'/create_table.inc';
  14. /* insert the first LOB */
  15. $ora_sql = "INSERT INTO
  16. ".$schema.$table_name." (blob)
  17. VALUES (empty_blob())
  18. RETURNING
  19. blob
  20. INTO :v_blob ";
  21. $s = oci_parse($c,$ora_sql);
  22. $blob = oci_new_descriptor($c,OCI_DTYPE_LOB);
  23. oci_bind_by_name($s,":v_blob", $blob,-1,OCI_B_BLOB);
  24. oci_execute($s, OCI_DEFAULT);
  25. var_dump($blob->write("first lob data"));
  26. oci_commit($c);
  27. /* insert the second LOB */
  28. $ora_sql = "INSERT INTO
  29. ".$schema.$table_name." (blob)
  30. VALUES (empty_blob())
  31. RETURNING
  32. blob
  33. INTO :v_blob ";
  34. $s = oci_parse($c,$ora_sql);
  35. $blob = oci_new_descriptor($c,OCI_DTYPE_LOB);
  36. oci_bind_by_name($s,":v_blob", $blob,-1,OCI_B_BLOB);
  37. oci_execute($s, OCI_DEFAULT);
  38. var_dump($blob->write("second lob data"));
  39. oci_commit($c);
  40. /* select both */
  41. $ora_sql = "SELECT blob FROM ".$schema.$table_name;
  42. $s = oci_parse($c,$ora_sql);
  43. oci_execute($s, OCI_DEFAULT);
  44. $rows = array();
  45. $rows[0] = oci_fetch_assoc($s);
  46. $rows[1] = oci_fetch_assoc($s);
  47. var_dump($rows[0]['BLOB']->read(1000));
  48. var_dump($rows[1]['BLOB']->read(1000));
  49. require __DIR__.'/drop_table.inc';
  50. echo "Done\n";
  51. ?>
  52. --EXPECT--
  53. int(14)
  54. int(15)
  55. string(14) "first lob data"
  56. string(15) "second lob data"
  57. Done