略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: OCI-Lob::export

2024-12-26

OCI-Lob::export

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

OCI-Lob::exportExports LOB's contents to a file

说明

OCI-Lob::export ( string $filename [, int $start [, int $length ]] ) : bool

Exports LOB contents to a file.

参数

filename

Path to the file.

start

Indicates from where to start exporting.

length

Indicates the length of data to be exported.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

add a note add a note

User Contributed Notes 1 note

up
-1
AlexiuS
6 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."!");
    }
}
?>

官方地址:https://www.php.net/manual/en/oci-lob.export.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3