PHP Velho Oeste 2024

OCILob::load

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

OCILob::loadRetourne le contenu d'un LOB

Description

OCILob::load ( ) : string

Lit le contenu d'un LOB Oracle. Le script peut être interrompu à cause de memory_limit, si ce dernier dépasse la limite. Dans la plupart des cas, il est recommandé d'utiliser la fonction OCILob::read à la place. En cas d'erreur, OCI-Lob->load() retourne false.

Valeurs de retour

Retourne le contenu de l'objet, ou false si une erreur survient.

Historique

Version Description
8.0.0, PECL OCI8 3.0.0 La classe OCI-Lob a été renommée en OCILob pour aligner avec les standards de nommage PHP.

Voir aussi

add a note add a note

User Contributed Notes 2 notes

up
0
FaLL3N at mail dot ru
17 years ago
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 :)
up
-1
FaLL3N at mail dot ru
17 years ago
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!
To Top