lob_002.phpt 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. --TEST--
  2. oci_lob_write() and friends (with errors)
  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 lob_002_tab",
  16. "create table lob_002_tab (id number, b1 BLOB)",
  17. );
  18. oci8_test_sql_execute($c, $stmtarray);
  19. $statement = oci_parse($c, "insert into lob_002_tab (id, b1) values (1, empty_blob()) returning b1 INTO :v_blob ");
  20. $blob = oci_new_descriptor($c,OCI_D_LOB);
  21. oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
  22. oci_execute($statement, OCI_DEFAULT);
  23. var_dump($blob);
  24. var_dump($blob->write("test", -1));
  25. var_dump($blob->write("test", 1000000));
  26. var_dump($blob->write(str_repeat("test", 10000), 1000000));
  27. var_dump($blob->tell());
  28. var_dump($blob->flush());
  29. oci_commit($c);
  30. $select_sql = "select b1 from lob_002_tab where id = 1";
  31. $s = oci_parse($c, $select_sql);
  32. oci_execute($s);
  33. $row = oci_fetch_array($s, OCI_RETURN_LOBS);
  34. var_dump(strlen($row[0]));
  35. // Cleanup
  36. $stmtarray = array(
  37. "drop table lob_002_tab"
  38. );
  39. oci8_test_sql_execute($c, $stmtarray);
  40. ?>
  41. --EXPECTF--
  42. object(OCILob)#%d (1) {
  43. ["descriptor"]=>
  44. resource(%d) of type (oci8 descriptor)
  45. }
  46. int(0)
  47. int(4)
  48. int(40000)
  49. int(40004)
  50. bool(false)
  51. int(40004)