OCILob::export

(PHP 5, PHP 7, PHP 8, PECL OCI8 >= 1.1.0)

OCILob::exportLOB の内容をファイルに出力する

説明

OCILob::export(string $filename, int $start = ?, int $length = ?): bool

LOB の内容をファイルに出力します。

パラメータ

filename

ファイルへのパス。

start

出力を開始する位置。

length

出力するデータの長さ。

返り値

成功した場合に true を、失敗した場合に false を返します。

変更履歴

バージョン 説明
8.0.0, PECL OCI8 3.0.0 OCI-Lob クラスは、 PHP の名前付けの規約に従って OCILob に名前が変更されました。
add a note add a note

User Contributed Notes 1 note

up
-1
AlexiuS
11 years ago
Please note, that contents of LOB is cleared after this operation. If you want to use LOB data after exporting it to file, you should read it from file with file_get_contents().

This will not work:
<?php
if($blob) {
   
$filename = DOCUMENT_ROOT."/".$bildId.".jpg";
    if(
$blob->export($filename)) {
        while(!
$blob->eof()){
           
$dbResult .= $blob->read(2000);
        }
    } else {
        throw new
Exception("Can not save the file ".$filename."!");
    }
}
?>

Use this instead:
<?php
if($blob) {
   
$filename = DOCUMENT_ROOT."/".$bildId.".jpg";
    if(
$blob->export($filename)) {
       
$dbResult = file_get_contents($filename);
    } else {
        throw new
Exception("Can not save the file ".$filename."!");
    }
}
?>
To Top