php, postgresql and graphical images

Mihail Mihailov <[email protected]>
Newsgroups gmane.comp.db.postgresql.php
Message-ID <[email protected]>
Hi all!

Does anybody have any experience in displaying images stored in  
postgresql database?
I'm trying to export image into file using pg_lo_export function and  
then view it on html page. However, the pg_lo_export seem to work only  
occasionaly.

The code is like this:
(php5, postgresql 8.2)
*****************
$no++; //Incerementing number of the image
pg_query("Begin");
$query = "select pic_data, accurateness_level, mime_type from image2 where
           *****//condition clause";
$row = pg_fetch_row(pg_query($query));
// Get the image OID
$image = $row[0];
// Get the type of the picture
$type = $row[2];
// Export the picture into pic.type
pg_lo_export($image, "pic$no.$type");
//get image file dimensions
$dimensions = getimagesize("pic$no.$type");
$width = $dimensions[0];
$height = $dimensions[1];
// Show the picture
echo "<img src=\"pic$no.$type\" width=" . $width . " height=" .  
$height  . "/>";
pg_query("Commit");
*************

I understand that the script doesn't like the idea of saving files on  
the server. However, why does it work at all?
Are there any other ways to export images from the database?

Any comments are welcome.

- Mike

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.