|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-10-23 04:40 UTC] sherman dot chan at world dot net
Description:
------------
I tried to insert a blob data to my IBM DB2 database, verions 8.1, though PHP with ibm_db2-1.5.1, the script ran ok, it did not give me any error, but I found no data was inserted.
db schema
create table test_blob (
tcode character(10),
tblob blob
);
BTW, I db2_exec() to create a table with the schema on above witout any problem, I can see the table with db2 cli
I just wonder did I missed anything, I have have tried pass an array to db2_execute () instead of using db2_bind_param(), but still no luck.
Thanks
Sherman
Reproduce code:
---------------
<?
$db2host ="xxx.xxx.xxx.xxx";$db2uid = "db2inst1";
$db2pwd = "db2inst1";$db2port = "50004";
$connStr = "DRIVER={IBM DB2 ODBCDRIVER};DATABASE=TEST;".
"HOSTNAME=$db2host;PORT=$db2port;". "PROTOCOL=TCPIP;UID=$db2uid;PWD=$db2pwd;";
$conn = db2_connect ($connStr, '', '');
$sql = "insert into test_blob (tcode, tblob) values (?, ?) ";
$stml = db2_prepare ($conn, $sql);
db2_bind_param ($stml, 1, "tcode", DB2_CHAR, DB2_PARAM_IN);
db2_bind_param ($stml, 2, "tblob", DB2_BINARY,DB2_PARAM_IN);
db2_execute ($stml);
db2_commit ($conn);
$sql = "select count(*) from twn_php_object";
$stml = db2_exec ($conn, $sql);
while ($res = db2_fetch_array($stml)) {
var_dump ($res);
}
?>
Expected result:
----------------
I expect the result
array(1) {
[0]=>
int(1)
}
Actual result:
--------------
array(1) {
[0]=>
int(0)
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 16:00:01 2025 UTC |
Hi Sherman, I am a bit confused on what you are trying to do in your PHP script. I see a few issues with your script. I am able to insert a BLOB with no issues. Please look over the script below, and if you have any other questions, feel free to email me. Thanks, --Kellen (kfbombar) <?php $conn = db2_connect('sample', 'db2inst1', '*******'); db2_exec($conn, "create table test_blob (tcode character(10), tblob blob)"); $sql = "insert into test_blob (tcode, tblob) values (?, ?) "; $stml = db2_prepare ($conn, $sql); $tcode = "1"; $tblob = dirname(__FILE__) . "/some_binary_file.jpg"; db2_bind_param ($stml, 1, "tcode", DB2_CHAR, DB2_PARAM_IN); db2_bind_param ($stml, 2, "tblob", DB2_PARAM_FILE, DB2_BINARY, DB2_PARAM_IN); db2_execute ($stml); db2_commit ($conn); $sql = "select count(*) from test_blob"; $stml = db2_exec ($conn, $sql); while ($res = db2_fetch_array($stml)) { var_dump ($res); } ?>