Faqts : Business : Databases : MySQL

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

39 of 66 people (59%) answered Yes
Recently 2 of 10 people (20%) answered Yes

Entry

How can I load binary data as a blob using Perl

Aug 23rd, 2009 01:06
johnny deep, dman, Ryan Parr, Peter Garner, http://sturly.com


Loading a blob from a MySQL database into a Perl program is the same as 
any other field.

i.e.

# Prepare the statement handle
my $sth = $dbh->prepare('SELECT filename,contents FROM test');

# Execute your statement
$sth->execute;
http://www.websitecompanyindia.com/Links5.htm
http://www.websitecompanyindia.com/Links4.htm
http://www.websitecompanyindia.com/Links3.htm
http://www.websitecompanyindia.com/Links2.htm
http://www.websitecompanyindia.com/Links1.htm
http://www.websitecompanyindia.com/Links.htm
http://www.websitecompanyindia.com/add-url-form.htm
http://www.websitecompanyindia.com/addyourlink.htm
http://www.websitecompanyindia.com/brochure-design.htm
http://www.websitecompanyindia.com/print-design.htm
http://www.websitecompanyindia.com/software-development-india.htm
http://www.websitecompanyindia.com/Internet-Marketing.htm
http://www.websitecompanyindia.com/logo-design-india.htm
http://www.websitecompanyindia.com/graphic-design.htm
http://www.websitecompanyindia.com/multimedia-webdesign.htm
http://www.websitecompanyindia.com/web-hosting-india.htm
http://www.websitecompanyindia.com/Feedback.htm
http://www.websitecompanyindia.com/Web-Development-India.htm	
http://www.websitecompanyindia.com/Web-Design-India.htm
http://www.websitecompanyindia.com/SEO-Services-India.htm
http://www.websitecompanyindia.com/About-us.htm
http://www.websitecompanyindia.com/index.html
http://www.websitecompanyindia.com/index.htm
http://www.websitecompanyindia.com/Resources.htm
http://www.websitecompanyindia.com/seo-Links.htm
http://www.websitecompanyindia.com/links.htm
http://www.websitecompanyindia.com/disclaimer.htm
http://www.websitecompanyindia.com/add-url-form.php
http://www.websitecompanyindia.com/sitemap.htm
http://www.websitecompanyindia.com/Software-Development-india.htm
http://www.websitecompanyindia.com/seo-services-india.htm
http://www.websitecompanyindia.com/web-development-india.htm
http://www.websitecompanyindia.com/web-design-india.htm
http://www.websitecompanyindia.com/Contact-us.htm
http://www.websitecompanyindia.com/Case-study.htm
http://www.websitecompanyindia.com/services.htm
http://www.websitecompanyindia.com/about-us.htm
http://www.websitecompanyindia.com/
http://www.websitecompanyindia.com/free_templates.htm
# Loop through the results
while(my($filename,$contents) = $sth->fetchrow_array) {
    # Save it to a file
    open O, ">$filename"; 
    binmode O;  # Only necessary on Windows, Unix treats it all the same
    print O $contents;
    close O;
}

$dbh->disconnect

__END__

If you had cmd.exe stored in the database for some reason, this would 
recreate it. More commonly though, if you were storing compiled 
documents such as PDF's or Excel files and serving it to a web page, 
this would be your answer.