Front page | perl.books.workers |
Postings from August 2002
From: Uri Guttman
August 28, 2002 20:40
Message ID: firstname.lastname@example.org
>>>>> "IT" == Iain Truskett <email@example.com> writes:
IT> How does one actually go about inserting and retrieving binary data from
IT> a database?
IT> my $sth = $dbh->prepare('insert into covers (isbn,small) values (?,?)');
IT> $sth->execute($isbn, $imagedata);
IT> Because that's not working for me.
no, you must convert it first to a string by using storable (freeze
method) or some other module. then you can insert it into a long field
of type BLOB.
when you read it from the DB you do the conversion from text to binary
(thaw method) and assign it to your variable. make this image access a
cgi/url for the IMG tag and it should work fine.
Uri Guttman ------ firstname.lastname@example.org -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org