lob_044.phpt 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. --TEST--
  2. oci_lob_truncate() with default parameter value
  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_044_tab",
  16. "create table lob_044_tab (blob BLOB)",
  17. );
  18. oci8_test_sql_execute($c, $stmtarray);
  19. // Run Test
  20. echo "Test 1 - truncate on insert\n";
  21. $s = oci_parse($c, "INSERT INTO lob_044_tab (blob) VALUES (empty_blob()) RETURNING blob INTO :v_blob ");
  22. $blob = oci_new_descriptor($c, OCI_D_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("this is a biiiig faaat test string. why are you reading it, I wonder? =)"));
  26. var_dump($blob->seek(0));
  27. var_dump($blob->read(10000));
  28. var_dump($blob->truncate());
  29. var_dump($blob->seek(0));
  30. var_dump($blob->read(10000));
  31. oci_commit($c);
  32. // Read it back
  33. echo "\nTest 2 - read it back\n";
  34. $s = oci_parse($c, "SELECT blob FROM lob_044_tab FOR UPDATE");
  35. oci_execute($s, OCI_DEFAULT);
  36. $row = oci_fetch_array($s);
  37. var_dump($row[0]->read(10000));
  38. // Clean up
  39. $stmtarray = array(
  40. "drop table lob_044_tab"
  41. );
  42. oci8_test_sql_execute($c, $stmtarray);
  43. ?>
  44. --EXPECT--
  45. Test 1 - truncate on insert
  46. int(72)
  47. bool(true)
  48. string(72) "this is a biiiig faaat test string. why are you reading it, I wonder? =)"
  49. bool(true)
  50. bool(true)
  51. string(0) ""
  52. Test 2 - read it back
  53. string(0) ""