tags:

views:

22

answers:

2

I'm writing php web-app using unholy alliance of php+oracle+iis :) every time script being executed I create a new connection to db - and it takes time:

class ORACLE_layer {

    public function __construct($usr, $pwd, $db) {
        $this->conn = oci_connect ("...")
    }

    function __destruct() {
       oci_close($this->conn);
    }
}

I heard of "persistent connections". Should I use them? "oci_pconnect" Do I need to remove the line: "oci_close($this->conn);" from "__destruct"?

+1  A: 

Whether you should use them or not cannot be answered without some consideration:

Using oci_pconnect() makes a big improvement in overall connection speed of frequently used applications because it uses the connection cache in PHP. A new, physical connection to the database does not have to be created if one already exists in PHP’s cache. However if currently unused, open persistent connections consume too much memory on the database server, consider tuning the timeout parameters or using connection pooling.

Check out

to learn more about connecting to Oracle from PHP efficiently.

Gordon
Just to add to Gordon's answer - you're only going to get a benefit using persistent conenctions if the PHP is not running as a CGI i.e. for IIS it needs to run as fastCGI
symcbean
A: 

Check out datable resident connection pools available as of 11.2. This will resolve your issue.

erbsock