From:             ceco at noxis dot net
Operating system: windows 2000 server
PHP version:      4.3.4
PHP Bug Type:     OCI8 related
Bug description:  binding blobs to procedure params corrupts them

Description:
------------
first of all I should say that it may be documentation problem, because
didn't find good documentation of the LOB object 

i have a oracle procedure, which accepts BLOB

(see the code below)

it inputs the data in the blob but when i extract (with the oracle tools
or with other php script) it is corrupted it is exactly 2 times larger
when everything is changed to clob (of course the data is text not jpg),
this function work ok

also it is workig for me if I use insert into (the_blob) values
(empty_blob()) returning the_blob into :the_blob

and then bind $lob and use $lob->save

but i don't want to have this

I think $lob->WriteTemporary mangles the data somehow and corrupts it

Reproduce code:
---------------
        include_once 'config/environment.inc.php';

        $fd = fopen('Sample.jpg', 'r');
        $data = fread($fd, filesize('Sample.jpg'));
        fclose($fd);

        $conn = ocilogon($CFG_DB['username'], $CFG_DB['password'],
$CFG_DB['db']);
        $lob = OCINewDescriptor($conn, OCI_D_LOB);

        $stmt = OCIParse($conn,"begin TEST_PROC(:the_blob); end;");
        OCIBindByName($stmt, ':the_blob', &$lob, -1, OCI_B_BLOB);
        $lob->WriteTemporary($data);
        OCIExecute($stmt, OCI_DEFAULT);
        $lob->close();
        $lob->free();
        OCICommit($conn);


create procedure TEST_PROC(the_blob blob) is
begin
insert into test_table values (the_blob);
end;

create table test_table (the_blob blob);


-- 
Edit bug report at http://bugs.php.net/?id=27083&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=27083&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=27083&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=27083&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=27083&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=27083&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=27083&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=27083&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=27083&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=27083&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=27083&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=27083&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=27083&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27083&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=27083&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=27083&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=27083&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27083&r=float

Reply via email to