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