Rüdiger Wenig: Textdatei in Oracle als BLOB speichern?

Beitrag lesen

Falls Du die Texte doch direkt in Oracle ablegen willst, hier eine Anleitung für Grafikdateien:

<?php
$conn=OCILogon("muenz","andriz");
$lob=OCINewDescriptor($conn, OCI_D_LOB);
$stmt = OCIParse($conn,"insert into images_tb (id, the_blob) values(my_seq.NEXTVAL, EMPTY_BLOB()) returning the_blob into :the_blob");
OCIBindByName($stmt, ':the_blob', &$lob, -1, OCI_B_BLOB);
OCIExecute($stmt, OCI_DEFAULT);
$lob->savefile("/folders/1.gif");
OCICommit($conn);
OCIFreeDescriptor($lob);
OCIFreeStatement($stmt);
OCILogoff($conn);
?>

Zur Anzeige im Browser:
<img src="getimg.php?img_id=100">

Hier die getimg.php:
<?php
<?php
$conn=OCILogon("muenz","andriz");
$stmt = OCIParse($conn,"select the_blob from images_tb where id=$img_id");
OCIExecute($stmt);
OCIFetchInto($stmt, $lob);
$content=$lob->load();
OCIFreeStatement($stmt);
OCILogoff($conn);
header("Content-type: image/gif\n\n");
echo $content;
?>