I have written a simple OCI wrapper class in PHP which uses persistent connections (oci_pconnect
). The class destructor calls oci_close
.
This class is used for all my AJAX PHP scripts and so is called a lot. However, despite using persistent connections and oci_close
not removing these from the cache (as per my understanding), the number of open connections to the database is maxing out, causing the system to fail. I was expecting the number of open connections to be just one for the whole app!
Am I doing something obviously wrong?
Skeleton code:
class Oracle {
private $connection;
private $connected;
function __construct($connectionString, $username, $password) {
if (!($this->connection = @oci_pconnect($username, $password, $connectionString))) {
echo 'Cannot connect to '.$username.'@'.$connectionString;
$this->connected = false;
} else {
$this->connected = true;
}
}
function __destruct() {
if ($this->connected) {
oci_close($this->connection);
}
}
}