php-src/ext/oci8/tests/lob_017.phpt
Antony Dovgal d99f05f1a2 add _not yet 100% complete_ Unicode support
collections, statements and BLOBs seem to be working ok
though there are still some things to be done in order to make oci_bind_array_by_name() work with U-strings

Notes:
- in Unicode mode OCI8 always speaks to Oracle server using UTF-16, so all the conversions are done by the client lib.
This is why character set parameter of oci_connect() and NLS_LANG are ignored in U-mode.

- BLOBs and CLOBs behave quite differently in U-mode.
Reading data from a CLOB would result in Unicode string, while BLOBs would return binary string.
Also, all LOB utilities work with _bytes_ when BLOB is used and _characters_ when it's CLOB.
It's not that obvious, but it does make a lot of sense to me.
2006-11-10 16:56:19 +00:00

86 lines
1.7 KiB
PHP

--TEST--
returning multiple lobs (using persistent connection)
--SKIPIF--
<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
--FILE--
<?php
require dirname(__FILE__).'/connect.inc';
$c = oci_pconnect($user, $password, $dbase);
$drop = "DROP table lob_test";
$statement = oci_parse($c, $drop);
@oci_execute($statement);
$create = "CREATE table lob_test(lob_1 BLOB, lob_2 BLOB)";
$statement = oci_parse($c, $create);
oci_execute($statement);
$init = "INSERT INTO lob_test VALUES(EMPTY_BLOB(), EMPTY_BLOB())";
$statement = oci_parse($c, $init);
oci_execute($statement);
$select = "SELECT * FROM lob_test FOR UPDATE";
$statement = oci_parse($c, $select);
oci_execute($statement, OCI_DEFAULT);
$row = oci_fetch_assoc($statement);
$row['LOB_1']->write(b"first");
$row['LOB_2']->write(b"second");
unset($row);
oci_commit($c);
$select = "SELECT * FROM lob_test FOR UPDATE";
$statement = oci_parse($c, $select);
oci_execute($statement, OCI_DEFAULT);
$row = oci_fetch_assoc($statement);
var_dump($row);
var_dump($row['LOB_1']->load());
var_dump($row['LOB_2']->load());
$drop = "DROP table lob_test";
$statement = oci_parse($c, $drop);
@oci_execute($statement);
echo "Done\n";
?>
--EXPECTF--
array(2) {
["LOB_1"]=>
object(OCI-Lob)#%d (1) {
["descriptor"]=>
resource(%d) of type (oci8 descriptor)
}
["LOB_2"]=>
object(OCI-Lob)#%d (1) {
["descriptor"]=>
resource(%d) of type (oci8 descriptor)
}
}
string(5) "first"
string(6) "second"
Done
--UEXPECTF--
array(2) {
[u"LOB_1"]=>
object(OCI-Lob)#%d (1) {
[u"descriptor"]=>
resource(%d) of type (oci8 descriptor)
}
[u"LOB_2"]=>
object(OCI-Lob)#%d (1) {
[u"descriptor"]=>
resource(%d) of type (oci8 descriptor)
}
}
string(5) "first"
string(6) "second"
Done