Postgresql Large Objhect
| From: | Unknown Sender | Date: | Sat, 26 Aug 2000 04:34:56 +0000 |
| Subject: | Postgresql Large Objhect | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-13770@lists.php.net to get a copy of this message | ||
Hi All,
I can't seem to get my PHP script to read in a postgres large object. I
know the object exists as I can do a select lo_export(image,
<filename) from images; and it works. The code I've got is as follows. The
result I get is 'ERROR: lo_lseek: invalid large obj descriptor (0)'.
Thanks,
Shaun
$qImage = "select image from images where auction_id = " . $auction_id;
$rImage = pg_exec($qImage);
if (!$rImage)
exit;
if (pg_numRows($rImage) != 1)
exit;
// Try to open the large object
$res = pg_fetch_array($rImage, 0);
print $res['image'] . "<BR>I am here!<BR>";
if (!($resId = pg_loopen($db, $res['image'], "rw"))) {
print pg_errormessage($db);
exit;
}
// Give them the appropriate mime headers
header("Content-Type: image/jpeg");
// Rip the data out of the large object interface
pg_loreadall($resId);
pg_loclose($resId);