1--TEST--
2bind LONG field
3--EXTENSIONS--
4oci8
5--SKIPIF--
6<?php
7$target_dbs = array('oracledb' => true, 'timesten' => false);  // test runs on these DBs
8require(__DIR__.'/skipif.inc');
9?>
10--FILE--
11<?php
12
13require(__DIR__."/connect.inc");
14
15$stmt = oci_parse($c, "drop table phptestlng");
16@oci_execute($stmt);
17
18$stmt = oci_parse($c, "create table phptestlng( id number(10), filetxt long)");
19oci_execute($stmt);
20
21echo "Test 1\n";
22
23$stmt = oci_parse ($c, "insert into phptestlng (id, filetxt) values (:id, :filetxt)");
24$i=1;
25$filetxt1 = file_get_contents( __DIR__."/test.txt");
26$filetxt = str_replace("\r", "", $filetxt1);
27
28oci_bind_by_name( $stmt, ":id", $i, -1);
29oci_bind_by_name( $stmt, ":filetxt", $filetxt, -1, SQLT_LNG);
30oci_execute($stmt, OCI_DEFAULT);
31oci_commit($c);
32
33$stmt = oci_parse($c, "SELECT filetxt FROM phptestlng where id = 1");
34oci_execute($stmt);
35
36$row = oci_fetch_row($stmt);
37var_dump(md5($row[0]));
38var_dump(strlen($row[0]));
39
40echo "Test 2 - test multi chunk fetch\n";
41
42$stmt = oci_parse ($c, "insert into phptestlng (id, filetxt) values (:id, :filetxt)");
43$i=2;
44$filetxt = str_repeat($filetxt, 600);
45
46oci_bind_by_name( $stmt, ":id", $i, -1);
47oci_bind_by_name( $stmt, ":filetxt", $filetxt, -1, SQLT_LNG);
48oci_execute($stmt, OCI_DEFAULT);
49oci_commit($c);
50
51$stmt = oci_parse($c, "SELECT filetxt FROM phptestlng where id = 2");
52oci_execute($stmt);
53
54$row = oci_fetch_row($stmt);
55var_dump(md5($row[0]));
56var_dump(strlen($row[0]));
57
58$stmt = oci_parse($c, "drop table phptestlng");
59oci_execute($stmt);
60
61echo "Done\n";
62
63?>
64--EXPECT--
65Test 1
66string(32) "5c7c34abf7ea51936785062dbfcaeddc"
67int(394)
68Test 2 - test multi chunk fetch
69string(32) "ee2e98b977341cfb8e037066e5fcb909"
70int(236400)
71Done
72