Entry from within tnsnames.ora file
ORA_SERVICE = (DESCRIPTION = (ADDRESS = (PROTOCOL = tcp)(HOST = localhost)(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME=ora_service)))
This is sample script to connect and execute a query:
$db_conn["host"] = "ORA_SERVICE"; # service name in the tnsnames.ora file
$db_conn["user"] = "myuser"; # username
$db_conn["pass"] = "mypass"; # password
$db_conn["library"] = "OCI";
$connect_id = ocilogon($db_conn["user"], $db_conn["pass"], $db_conn["host"]);
$query = "SELECT * FROM table";
$statement = ociparse($connect_id, $query);
ociexecute($statement);
$result = array(); while(ocifetchinto($statement, $tmp, OCI_ASSOC + OCI_RETURN_NULLS + OCI_RETURN_LOBS)) {
array_push($result, $tmp); }
ocifreestatement($statement);
var_dump($result); # result is here
Please also review this connection link for PHP - http://www.php.net/manual/en/function.oci-connect.php