<?
include ("connection.php");

$id=$_GET["id"];
	

header('Content-type: image/jpg');

	
$requete = "SELECT \"IMAGE\",\"THUMBNAIL\" FROM \"PICTURE\" where \"PICTURE_ID\" = $id";
	pg_query ($c, "begin");
	$stmt=pg_query($c,$requete);
	$row = pg_fetch_array($stmt);
	$lo_oid=$row["IMAGE"];

$handle_lo = pg_lo_open($c,$lo_oid,"r") or die("<h1>Error.. can't get handle</h1>");
pg_lo_read_all($handle_lo) or die("<h1>Error, can't read large object.</h1>");

	pg_query($c, "commit");

?>