lob_006.phpt 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. --TEST--
  2. oci_lob_write()/truncate()/erase()
  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. $ora_sql = "INSERT INTO
  15. ".$schema.$table_name." (blob)
  16. VALUES (empty_blob())
  17. RETURNING
  18. blob
  19. INTO :v_blob ";
  20. $statement = oci_parse($c,$ora_sql);
  21. $blob = oci_new_descriptor($c,OCI_D_LOB);
  22. oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
  23. oci_execute($statement, OCI_DEFAULT);
  24. var_dump($blob);
  25. $str = "this is a biiiig faaat test string. why are you reading it, I wonder? =)";
  26. var_dump($blob->write($str));
  27. var_dump($blob->truncate());
  28. var_dump($blob->seek(0, OCI_SEEK_SET));
  29. var_dump($blob->write("string was here. tick-tack-tick-tack."));
  30. var_dump($blob->erase(10, 10));
  31. var_dump($blob->write("some"));
  32. oci_commit($c);
  33. $select_sql = "SELECT blob FROM ".$schema.$table_name." FOR UPDATE";
  34. $s = oci_parse($c, $select_sql);
  35. oci_execute($s, OCI_DEFAULT);
  36. var_dump($row = oci_fetch_array($s));
  37. var_dump($row[0]->read(10000));
  38. require __DIR__.'/drop_table.inc';
  39. echo "Done\n";
  40. ?>
  41. --EXPECTF--
  42. object(OCILob)#%d (1) {
  43. ["descriptor"]=>
  44. resource(%d) of type (oci8 descriptor)
  45. }
  46. int(72)
  47. bool(true)
  48. bool(true)
  49. int(37)
  50. int(10)
  51. int(4)
  52. array(2) {
  53. [0]=>
  54. object(OCILob)#%d (1) {
  55. ["descriptor"]=>
  56. resource(%d) of type (oci8 descriptor)
  57. }
  58. ["BLOB"]=>
  59. object(OCILob)#%d (1) {
  60. ["descriptor"]=>
  61. resource(%d) of type (oci8 descriptor)
  62. }
  63. }
  64. string(41) "string was%0%0%0%0%0%0%0%0%0%0k-tack-tick-tack.some"
  65. Done