Précédent   Forum des professionnels en informatique > PHP > PHP & SGBD > PHP & Oracle
PHP & Oracle Forum d'entraide sur Oracle avec PHP. Avant de poster -> FAQ Oracle et Cours Oracle
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 15/01/2008, 15h19   #1
Membre éclairé
 
Homme Damien Attanasio
Développeur informatique
Inscription : février 2007
Messages : 340
Détails du profil
Informations personnelles :
Nom : Homme Damien Attanasio
Localisation : France, Hérault (Languedoc Roussillon)

Informations professionnelles :
Activité : Développeur informatique
Secteur : Transports

Informations forums :
Inscription : février 2007
Messages : 340
Points : 307
Points : 307
Par défaut Enregistrer fichier dans un champs de type BLOB

Bonjour à tous !

Depuis ce matin, j'essai désespérément d'enregistrer un fichier PDF dans ma base de données par le biais d'un type BLOB.

J'ai beau tout tenter, ça ne marche pas. Quelqu'un saurait la syntaxe et comment faire ?

Code :
1
2
3
4
5
6
7
8
 
$requeteins = "insert into DOSSENT (DSE_FICHIER) values (EMPTY_BLOB()) returning DSE_FICHIER into :fichier";
$blob = ocinewdescriptor($conn, OCI_D_LOB);
$stmt = ociparse($conn,$requeteins);
OCIBindByName ($stmt, ":fichier", &$blob, -1, OCI_B_BLOB);
ociexecute($stmt);
$blob->import("devis.pdf");
ocicommit($conn);
Et il me retourne cette erreur
Code :
Warning: OCI-Lob::import() [function.OCI-Lob-import]: ORA-22990: LOB locators cannot span transactions in XXXX.php on line 24
Merci pour votre aide !
madevilts est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/01/2008, 08h46   #2
Membre éclairé
 
Homme Damien Attanasio
Développeur informatique
Inscription : février 2007
Messages : 340
Détails du profil
Informations personnelles :
Nom : Homme Damien Attanasio
Localisation : France, Hérault (Languedoc Roussillon)

Informations professionnelles :
Activité : Développeur informatique
Secteur : Transports

Informations forums :
Inscription : février 2007
Messages : 340
Points : 307
Points : 307
Après 6h de recherche intensive j'ai enfin trouvé la solution. Je vous la mets ici car elle est assez difficile à trouver sur le net !

Code :
1
2
3
4
5
6
7
8
9
10
$requeteins = "insert into DOSSENT (DSE_FICHIER) values (EMPTY_BLOB()) returning DSE_FICHIER into :fichier";
$blob = ocinewdescriptor($conn, OCI_D_LOB);
$stmt = ociparse($conn,$requeteins);
OCIBindByName ($stmt, ":fichier", &$blob, -1, OCI_B_BLOB);
ociexecute($stmt,OCI_DEFAULT);
$fichier = fopen($url,'rb');
if ($blob->save(fread($fichier,1000000)))
	ocicommit($conn);
ocifreestatement($stmt);
ocilogoff($conn);
Dans le cas d'un fichier "normal", vous pouvez faire directement un savefile comme ceci :
Code :
1
2
3
4
5
6
7
8
9
$requeteins = "insert into DOSSENT (DSE_FICHIER) values (EMPTY_BLOB()) returning DSE_FICHIER into :fichier";
$blob = ocinewdescriptor($conn, OCI_D_LOB);
$stmt = ociparse($conn,$requeteins);
OCIBindByName ($stmt, ":fichier", &$blob, -1, OCI_B_BLOB);
ociexecute($stmt,OCI_DEFAULT);
if ($blob->savefile($url))
	ocicommit($conn);
ocifreestatement($stmt);
ocilogoff($conn);
Dans mon cas, je ne peux pas car le savefile ne fonctionne pas car j'ouvre une page qui me génère du code PDF.
madevilts est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 08h01.


 
 
 
 
Partenaires

Hébergement Web