// 記住,大型物件必須從事務內取得
pg_query ($dbconn, "begin");
// 在此範例中,「假設」壓縮檔案的大型物件資源編號為「17899」
$lo_oid = 17899;
$handle_lo = pg_lo_open($dbconn,$lo_oid,"r") or die("<h1>錯誤.. 無法取得控制代碼</h1>");
// 在開始二進位下載之前要傳送到瀏覽器的標頭
header('Accept-Ranges: bytes');
header('Content-Length: 32029974'); // 這是壓縮檔案的大小
header('Keep-Alive: timeout=15, max=100');
header('Content-type: Application/x-zip');
header('Content-Disposition: attachment; filename="superjob.zip"');
pg_lo_read_all($handle_lo) or
die("<h1>錯誤,無法讀取大型物件。</h1>");
// 提交資料事務
pg_query ($dbconn, "commit");