Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open pdf blob from Oracle table

Status
Not open for further replies.

Moogles

MIS
Oct 6, 2002
37
US
Greeting from the PHP newbie!

I am trying to open a pdf file stored in oracle blob column. The following code always get the result:

Object id #1

Could someone tell me what that means and why I can't open the pdf file?

TIA

<?php
{
header("Content-type: application/pdf");
if ($conn=OCILogon("user", "password", "orcl")){

$query = "select text from pdffiles where id = 1";
$s = OCIParse($conn, $query);

OCIExecute($s);
OCIFetchInto($s,&$data,OCI_ASSOC);
echo($data["TEXT"]);

oci_free_statement($s);
oci_close($conn);

OCILogoff($conn);

}
}
?>

text is the column that I stored the pdf file.
pdffiles is the oracle table.
 
Have you tried the code in the manual i.e.
Code:
<?php
$conn = ocilogon("username", "password");

$query = "SELECT apples FROM oranges";

$statement = OCIParse ($conn, $query);
OCIExecute ($statement);

while (OCIFetchInto ($statement, $row, OCI_ASSOC)) {
   echo $row['apples'];
}
?>

I would think that your code might not always return the full blob as the fetch handler will only return in chunks.
 
Thanks Ingresman.
I just tried it, still gettting 'Object id #1'.
Do you know what that means?

TIA
 
Yes, it's the internal ID that the Oracle extention assigns to a resource.
Does it work with a normal select from a table i.e. not a blob?
 
Yes, I was able to echo out a character string from the same oracle table.

TIA
 
interesting, so you have manged to insert some text intothe blob, do you know if the .pdf got in correctly?,
can you post the new code please ?
 
Sorry, I may have confused you. I meant I was able to echo out a string from a different column that is not a blob type.

<?php
{
if ($conn=OCILogon("user", "password", "orcl")){

$s = OCIParse($conn, "SELECT description FROM pdffiles WHERE id = 1");

OCIExecute($s,OCI_DEFAULT);
while (OCIFetch($s)) {
echo "COL1=" . ociresult($s, "DESCRIPTION");
}

oci_free_statement($s);
oci_close($conn);

OCILogoff($conn);

}
}
?>
 
I've just been reading through the Oracle documentation in the PHP manual,
I think you should try lob->read and lob->eof.
Have a look and see what you think, Idont have an Oracle db so can't test anything for you.
You might want to put this thread into the Oracle forum as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top