This is the database connectivity script of PHP and ORACLE all the functional work are in the single file such as query,fetch, generate ID etc so everyone who really wants or working in php + oracle may get more help from it
Please see attached file above.
class.db.php
<?php
class db_connect{
var $sid, $connection;
var $query;
var $host;
var $total_record,$rec_position;
var $total_fields, $field_name;
/*This function connect to the database . This function is called
whenever object is created. */
function db_connect(){
$this->host="".ORCL_HOST."";
$this->sid="(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=".ORCL_HOST.")(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=".ORCL_SERVICE_NAME.")))";
$this->connection = ocilogon(ORCL_USER_NAME,ORCL_PASSWORD,$this->sid) or die ($this->get_error_msg($this->connection,"Problem while connecting to ".$this->sid." server..."));//username,password,sid
}
/*This function query at database */
function db_query($query_str="")
{
$this->sql=$query_str;
$this->rec_position=0;
// if($query_str==""){
// $query_str=$this->query_stmt;
//}
$this->query = @ociparse($this->connection, $query_str);
ociexecute($this->query)or die($this->get_error_msg($this->query ,"Query Error : ".$query_str));
}
/*This function query at database which returns TRUE if SUCCESSFUL and FALSE if UNSUCCESSFUL */
function db_query_return($query_str="",$db=""){
if($query_str==""){
$query_str=$this->query_stmt;
}
$this->query = ociparse($this->connection, $query_str);
if($db=="Default") {
return ociexecute($this->query,OCI_DEFAULT);
} else {
return ociexecute($this->query);
}
}