PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Show a BLOB field using MDB2

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> PEAR
View previous topic :: View next topic  
Author Message
Lino



Joined: 22 Apr 2009
Posts: 3
Location: Vera Cruz/RS - Brazil

PostPosted: Wed Apr 22, 2009 4:09 pm    Post subject: Show a BLOB field using MDB2 Reply with quote

I would like an example of how show a BLOB field of Firebird using MDB2?
Back to top
View user's profile Send private message
tmilos1



Joined: 17 Mar 2009
Posts: 8
Location: Krusevac, Serbia

PostPosted: Thu Apr 23, 2009 9:42 am    Post subject: Reply with quote

fetching lobs:
http://pear.php.net/manual/en/package.database.mdb2.intro-fetch.php

displaying on a page:
Header("Content-type: image/gif");
print $image;

displaying on a mixed page with html:
<image src="get_blob_image.php" />
Back to top
View user's profile Send private message
Lino



Joined: 22 Apr 2009
Posts: 3
Location: Vera Cruz/RS - Brazil

PostPosted: Thu Apr 23, 2009 9:20 pm    Post subject: save a image in disk Reply with quote

thanks, but now I need to save an image as a file.
I use this code to view the image:

Code:

<?php
  Header('Content-type: image/gif');
  include("./libs/AcessaKOPP.php");
  $temp_sql = "SELECT FOTO FROM INTEGRANTE where cod_integrante=8";
  $rs =& $mdb2->query($temp_sql, array('blob'));
  $row = $rs->fetchRow();

  $blob = $row[0];
  if (!PEAR::isError($blob) && is_resource($blob)) {
    $blob_value = '';
    while (!feof($blob)) {
        $blob_value .= fread($blob, 8192);
    }
    $mdb2->datatype->destroyLOB($blob);
  }
  $rs->free();
  print($blob_value."\n");

  // here I want to save the image as a file from the value of the variable  $blob_value
?>
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1235

PostPosted: Thu Apr 23, 2009 10:30 pm    Post subject: Reply with quote

Use file_put_contents() or fwrite().
Back to top
View user's profile Send private message
Lino



Joined: 22 Apr 2009
Posts: 3
Location: Vera Cruz/RS - Brazil

PostPosted: Fri Apr 24, 2009 2:17 pm    Post subject: Reply with quote

Thank you, helped me a lot
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> PEAR All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement