bind_long.phpt 1.7 KB

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