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