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 "per开发者_如何学Csistent connections". Should I use them? "oci_pconnect" Do I need to remove the line: "oci_close($this->conn);" from "__destruct"?
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
- The Underground PHP and Oracle Manual (quoted above)
- The PHP Oracle FAQ at the Oracle Wiki
- Oracle PHP Developer Center at OTN
to learn more about connecting to Oracle from PHP efficiently.
Check out datable resident connection pools available as of 11.2. This will resolve your issue.
精彩评论