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