OCILob::export

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

OCILob::exportExports LOB's contents to a file

说明

public OCILob::export ( string $filename , int|null $offset = null , int|null $length = null ) : bool

Exports LOB contents to a file.

参数

filename

Path to the file.

offset

Indicates from where to start exporting.

length

Indicates the length of data to be exported.

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0, PECL OCI8 3.0.0 offset and length are now nullable.
8.0.0, PECL OCI8 3.0.0 The OCI-Lob class was renamed to OCILob to align with PHP naming standards.

User Contributed Notes

AlexiuS 15-Mar-2013 01:30
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."!");
    }
}
?>
PHP8中文手册 站长在线 整理 版权归PHP文档组所有