OCILob::load

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

OCILob::loadReturns large object's contents

说明

public OCILob::load ( ) : string|false

Returns large object's contents. As script execution is terminated when the memory_limit is reached, ensure that the LOB does not exceed this limit. In most cases it's recommended to use OCILob::read instead.

参数

此函数没有参数。

返回值

Returns the contents of the object, or false on errors.

更新日志

版本 说明
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

FaLL3N at mail dot ru 25-Dec-2006 05:49
Ps. To prevent IE errors like 'File not found!' after downloading file from db I recommend to add next two lines into header:
header('Cache-Control: max-age=0');
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");

With this, IE will open any file normally :)
FaLL3N at mail dot ru 25-Oct-2006 06:34
I'll give you example how to download a file from db without storing it on server's FS:
It works like this - point yor browser to index.php?name=file.ext
Just make sure that file "file.ext" exists in your db!

Code:

<?php

 $dbConnection
=ocilogon('user','pass','data.world'); //login stuff
 
$sql_SelectBlob='select document_body,filename from tdocuments where id=1'; //selecting a blob field named 'document_body' with id = 1
 
$statement=OCIParse($dbConnection,$sql_SelectBlob);

 
OCIExecute($statement) or die($sql_SelectBlob.'<hr>');

if(
OCIFetch($statement)) //if file exists
 
{
 
$a=OCIResult($statement,"DOCUMENT_BODY");
 }
header('Content-type: application/octet-stream;');
header('Content-disposition: attachment;filename='.$_GET['name']);

print
$a->load();
//browser promts to save or open the file
?>

Have fun!
PHP8中文手册 站长在线 整理 版权归PHP文档组所有