|
intranet:
oci_pconnect1/oci_pconnect1.php Further reading :
http://www.php.net/manual/en/features.persistent-connections.php |
There are three ways to connect oracle db
- standard
- $conn = oci_connect($username, $password, $dbname);
- $conn = oci_connect('scott', 'Son', 'localhost/orcl.gateway.2wire.net');
- Unique
- $conn = oci_new_connect($username, $password, $dbname)
- $c2 = oci_new_connect('scott', 'Son', 'localhost/orcl.gateway.2wire.net');
- 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/orcl.gateway.2wire.net');
- 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:
<?php
//oci_pconnect1.php
$username ="";
function my_connect($un, $pw, $db)
{
if($un){
$username = $un;
}
return(oci_pconnect($un, $pw, $db));
}
session_start();
$ses_id = session_id();
$c = my_connect('scott', 'Son', 'localhost/orcl.gateway.2wire.net');
$s = oci_parse($c, 'select sysdate from dual');
//$s = oci_parse($c, 'select * from scott_log');
oci_execute($s);
$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'].
|
|
|
|