perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wim Kerkhoff <...@nyetwork.org>
Subject Re: Display Blob from database
Date Thu, 07 Nov 2002 08:26:28 GMT
Kee Hinckley wrote:

> At 5:36 PM -0800 11/4/02, Andrew Lim wrote:
>
>> I need to do this thing pretty soon for my new project.
>> I still don't get this instruction.
>> Specially how to "SPIT out" image from DB and while() part.
>>
>> Can you give us more detailed explanation?
>
>
> Not really, since I don't know what API you are using to retrieve 
> items from the database.  The URL to the script needs to be passed the 
> id of the database element.  The script itself needs to lookup the id 
> in the database, retrieve the field that contains the image, and print 
> it.

Exactly. Every database seems to have a different way of handling binary 
large objects. If using DBI, see the man page for the DBD driver that is 
being used (e.g. DBD::Oracle or DBD::mysql).

With some databases, it's as easy as doing:

print $dbh->selectrow_array("select image from content_images where 
id=12345");

With other database drivers, blobs get treated more like file handles, 
requiring data to be read into a temporary buffer, one chunk at a time. 
Typically, there are lots of examples and discussions of the pitfalls of 
BLOBs in various mailing list that can be found via Google.




---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Mime
View raw message