Thursday, November 18, 2010

Retrieving Image from Oracle using PHP

Storing image in Databases such as Oracle, MySQL is not recommended usually because it put an overload on Database engine and performance is compromised, but there are many scenarios when one had to put images in database mostly for security reasons. In this tutorial we will learn how to retrieve image or any other data which is serialized and saved in database, in our case database is Oracle and language we are using is PHP.
function getImage($id){
 header("Content-type: image/jpeg");
// tell system which type of data is comming.
// it must be set appropriately.
 $query="select image from table where ID=$id";
 $db= new DB();
 //initialize Database Class.
 $result=$db->execQuery($query);
//wrpper of mysql_query().
 $arr=oci_fetch_array($result, OCI_RETURN_NULLS);
 $temp=$arr[0]->load();
 echo $temp;
}

0 comments:

Post a Comment

 

Blog Info

A Pakistani Website by Originative Systems

Total Pageviews

Tutorial Jinni Copyright © 2015 WoodMag is Modified by Originative Systems