intranet: oci_pconnect1/oci_pconnect1.php

Further reading :

There are three ways to connect oracle db
  • standard
    • $conn = oci_connect($username, $password, $dbname);
    • $conn = oci_connect('scott', 'Son', 'localhost/');
  • Unique
    • $conn = oci_new_connect($username, $password, $dbname)
    • $c2 = oci_new_connect('scott', 'Son', 'localhost/');
  • Persistent : This connection stays open as a persistent connection cache for subsequent querying scripts using  the same.It reduces the overhead. Following a request, PHP checks for an identical connection using the same user name and the same password.
    • $c = oci_pconnect($username, $password, $dbname);
    • $c = oci_pconnect('scott', 'Son', 'localhost/');
    • Caution: This connection does not support to use 'user session',
    • Connection can be closed with oci_close
create table scott_log(
owner varchar2(30), time date);


php Script:

$username ="";
function my_connect($un, $pw, $db)
$username = $un;
return(oci_pconnect($un, $pw, $db));
$ses_id = session_id();
$c = my_connect('scott', 'Son', 'localhost/');
$s = oci_parse($c, 'select sysdate from dual');
//$s = oci_parse($c, 'select * from scott_log');
$row = oci_fetch_array($s, OCI_ASSOC);
echo $row['SYSDATE'] ." : your ip address :".$_SERVER['REMOTE_HOST']. " <br/>session " .$ses_id."<br>\n";
echo "hostig server : ". $_SERVER['SERVER_NAME'];

I used IIS7/FastCGI for php in this machine, Fastcgi would print temp thread.

The screen shot below taken from one of the intranet-client to host manas8x workstation. Please notice the default date format.

Now create procedure:

Create this trigger/ changing date format, and calling a stored procedure to insert date and the name of the current user.

Note date format changed: local host , note the local address

2014-02-13 : your ip address :fe80::1ded:c223:74f9:6d80%10
session a8t8ump4eiti9vo3besb4mfm53
hosting server : manas8x


Checking after few days:

Client from the same machine: $_SERVER['REMOTE_HOST'].

2014-02-17 : your ip address :fe80::1ded:c223:74f9:6d80%10
session svfk47lb15e2hmhskd470dbdu6
hosting server : manas8x

Intranet client: Note the ip address of the remote-client. ($_SERVER['REMOTE_HOST'].