> What do I have in mind? Well, since you ask....I want to store an image
> from a file into a blob from with php code using odbc. There's known
> issues with php&db2 trying to insert and retrieve blob (they both point
> the blame on the other and the issue is still open, from 2002).
You are probably referring to the old odbc-php driver that was used to talk
to DB2. This was not quite acceptable code. For example, there was no
support for LOBs at all. (It is definitively a PHP issue.) You should
rather stick with the newer Zend Core for IBM that handles stuff properly:
http://www-306.ibm.com/software/data/info/zendcore/
> So next
> I wanted just to try shell_exec a command line insert to insert a blob
> from a file.
> It doesn't even have to be a blob, I try to use clob and convert my
> image before insert....blah..blah...many tries, mostly ending up with
> only 4k of the image coming back out.
Those 4K might be the result from the truncation done by the DB2 CLP. The
whole LOB might actually be stored in the row.
> Is there a better way? I've searched for the last 2 days on this, and
> nothing. Everything points to the DB2 image extenders, which I havn't
> tried yet.
Unless you need some sort of image processing, the extender won't help you
either.

Signature
Knut Stolze
DB2 Information Integration Development
IBM Germany
yoyo - 21 Feb 2006 21:07 GMT
>>What do I have in mind? Well, since you ask....I want to store an image
>>from a file into a blob from with php code using odbc. There's known
[quoted text clipped - 23 lines]
> Unless you need some sort of image processing, the extender won't help you
> either.
Zend core. There's something I've not come across. I really wonder if it
will help me though, to store that image in a DB2 database.
The UDF I wanted from the image extender is the DB2IMAGE one, which
allows someone to do this from a command line:
insert into mytablewithblobcolum (CHARATT1,BLOBATT2) values
('ken',DB2IMAGE('/tmp/myjpg.jpg','jpg','26k'))
and it's supposed to take that jpeg and put it in your blob column.
If I have a true blob in there, I'm able to get it out with php odbc.
(I had to use the db2 import function to populate something in that
database with a blob though, I really don't want to use that as a
solution however)
I've never had a problem with odbc connector for db2 in php (until now),
been using for 3 years. I didn't even know of the zend core that IBM wrote.
I'll check out the code and see what's there. Is there native support
for blob then???? Hopefully....
Anyway, thatnks for the help, it's hope anyway,
ANy idea where those DB2 IMage extensions are in 8.1 or 2???????
Ken
Serge Rielau - 22 Feb 2006 14:15 GMT
>>> What do I have in mind? Well, since you ask....I want to store an image
>>> from a file into a blob from with php code using odbc. There's known
[quoted text clipped - 52 lines]
>
> Ken
Watch out for an article on BLOB in PHPs by Helmut Tessarek in the next
issue of php|architect magazine.
Cheers
Sege

Signature
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Knut Stolze - 22 Feb 2006 15:45 GMT
> Zend core. There's something I've not come across. I really wonder if it
> will help me though, to store that image in a DB2 database.
[quoted text clipped - 5 lines]
>
> and it's supposed to take that jpeg and put it in your blob column.
To be more precise, it takes an image that resides in a file in the file
system and stores it in the BLOB column. But that BLOB column exists in a
so-called side table and not your normal user table. Only a
reference/handle is stored in the user table.
If you want to go that route, I recommend that you have a look at the
article I cited as the Download includes a UDF "SI_loadImage" that does
exactly what you want with much less overhead. (You can also implement
something like this in Java if you like.)
> If I have a true blob in there, I'm able to get it out with php odbc.
> (I had to use the db2 import function to populate something in that
> database with a blob though, I really don't want to use that as a
> solution however)
You don't have to go over the file route. You can directly insert a BLOB
send from the client into the database. Here is a sample PHP script that
does just that:
http://tinyurl.com/r3oqg
Note that the script is still based on the old PHP ODBC driver, but that
driver was heavily modified.
And here is a script to extract BLOBs and send them (as PDF) to the client:
http://tinyurl.com/odcwf
> I've never had a problem with odbc connector for db2 in php (until now),
> been using for 3 years. I didn't even know of the zend core that IBM
> wrote. I'll check out the code and see what's there. Is there native
> support for blob then???? Hopefully....
Yes, BLOB support is there (besides that a lot of other bugs don't exist
there).

Signature
Knut Stolze
DB2 Information Integration Development
IBM Germany
yoyo - 22 Feb 2006 15:52 GMT
>>Zend core. There's something I've not come across. I really wonder if it
>>will help me though, to store that image in a DB2 database.
[quoted text clipped - 40 lines]
> Yes, BLOB support is there (besides that a lot of other bugs don't exist
> there).
Hey, thanks alot for those. That really helps! I've been playing with
the driver too, mabey I can get it to work.. I've checked out the Zend
core for IBM as well, looks nice, but in order for me to use I need to
change alot of things etc....I'll try it on my next project.