函式名:fbird_blob_echo()
適用版本:Firebird 2.0 及以上版本
用法:該函式用於從Firebird資料庫中讀取BLOB(Binary Large Object)資料,並將其直接輸出到瀏覽器。
示例:
<?php
$db = ibase_connect('localhost:employee.fdb', 'username', 'password');
$query = "SELECT blob_field FROM table_name WHERE id = 1";
$result = ibase_query($db, $query);
$row = ibase_fetch_assoc($result);
// 開始輸出BLOB資料
header('Content-type: application/octet-stream');
header('Content-Disposition: attachment; filename="blob_file.txt"');
fbird_blob_echo($row['BLOB_FIELD']);
ibase_free_result($result);
ibase_close($db);
?>
上述示例中,我們首先連線到Firebird資料庫,並執行一個查詢,獲取到包含BLOB資料的行。然後,我們設定了HTTP頭部,指定了輸出的內容型別為二進位制流,並設定了附件的檔名。最後,透過呼叫fbird_blob_echo()
函式,將BLOB資料直接輸出到瀏覽器。注意,在呼叫該函式之前,需要確保已經呼叫了ibase_connect()
函式連線到資料庫,並且已經獲取到了包含BLOB資料的行。
請注意,該函式僅適用於Firebird資料庫,並且要求Firebird的版本不低於2.0。