bind_long.phpt 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. --TEST--
  2. bind LONG field
  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. $stmt = oci_parse($c, "drop table phptestlng");
  12. @oci_execute($stmt);
  13. $stmt = oci_parse($c, "create table phptestlng( id number(10), filetxt long)");
  14. oci_execute($stmt);
  15. echo "Test 1\n";
  16. $stmt = oci_parse ($c, "insert into phptestlng (id, filetxt) values (:id, :filetxt)");
  17. $i=1;
  18. $filetxt = file_get_contents( dirname(__FILE__)."/test.txt");
  19. oci_bind_by_name( $stmt, ":id", $i, -1);
  20. oci_bind_by_name( $stmt, ":filetxt", $filetxt, -1, SQLT_LNG);
  21. oci_execute($stmt, OCI_DEFAULT);
  22. oci_commit($c);
  23. $stmt = oci_parse($c, "SELECT filetxt FROM phptestlng where id = 1");
  24. oci_execute($stmt);
  25. $row = oci_fetch_row($stmt);
  26. var_dump(md5($row[0]));
  27. var_dump(strlen($row[0]));
  28. echo "Test 2 - test multi chunk fetch\n";
  29. $stmt = oci_parse ($c, "insert into phptestlng (id, filetxt) values (:id, :filetxt)");
  30. $i=2;
  31. $filetxt = str_repeat($filetxt, 600);
  32. oci_bind_by_name( $stmt, ":id", $i, -1);
  33. oci_bind_by_name( $stmt, ":filetxt", $filetxt, -1, SQLT_LNG);
  34. oci_execute($stmt, OCI_DEFAULT);
  35. oci_commit($c);
  36. $stmt = oci_parse($c, "SELECT filetxt FROM phptestlng where id = 2");
  37. oci_execute($stmt);
  38. $row = oci_fetch_row($stmt);
  39. var_dump(md5($row[0]));
  40. var_dump(strlen($row[0]));
  41. $stmt = oci_parse($c, "drop table phptestlng");
  42. oci_execute($stmt);
  43. echo "Done\n";
  44. ?>
  45. --EXPECT--
  46. Test 1
  47. string(32) "5c7c34abf7ea51936785062dbfcaeddc"
  48. int(394)
  49. Test 2 - test multi chunk fetch
  50. string(32) "ee2e98b977341cfb8e037066e5fcb909"
  51. int(236400)
  52. Done