xref: /PHP-8.1/ext/oci8/tests/lob_044.phpt (revision b5a14e6c)
1--TEST--
2oci_lob_truncate() with default parameter value
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// Initialization
16
17$stmtarray = array(
18    "drop table lob_044_tab",
19    "create table lob_044_tab (blob BLOB)",
20);
21
22oci8_test_sql_execute($c, $stmtarray);
23
24
25// Run Test
26
27echo "Test 1 - truncate on insert\n";
28
29$s = oci_parse($c, "INSERT INTO lob_044_tab (blob) VALUES (empty_blob()) RETURNING blob INTO :v_blob ");
30$blob = oci_new_descriptor($c, OCI_D_LOB);
31oci_bind_by_name($s,":v_blob", $blob, -1, OCI_B_BLOB);
32oci_execute($s, OCI_DEFAULT);
33
34var_dump($blob->write("this is a biiiig faaat test string. why are you reading it, I wonder? =)"));
35var_dump($blob->seek(0));
36var_dump($blob->read(10000));
37var_dump($blob->truncate());
38var_dump($blob->seek(0));
39var_dump($blob->read(10000));
40
41oci_commit($c);
42
43
44// Read it back
45
46echo "\nTest 2 - read it back\n";
47
48$s = oci_parse($c, "SELECT blob FROM lob_044_tab FOR UPDATE");
49oci_execute($s, OCI_DEFAULT);
50$row = oci_fetch_array($s);
51var_dump($row[0]->read(10000));
52
53// Clean up
54
55$stmtarray = array(
56    "drop table lob_044_tab"
57);
58
59oci8_test_sql_execute($c, $stmtarray);
60
61?>
62--EXPECT--
63Test 1 - truncate on insert
64int(72)
65bool(true)
66string(72) "this is a biiiig faaat test string. why are you reading it, I wonder? =)"
67bool(true)
68bool(true)
69string(0) ""
70
71Test 2 - read it back
72string(0) ""
73