Pear-DB - Oracle persistent connection
| From: | Alf Magne Kalleland | Date: | Fri, 07 Mar 2003 14:22:50 +0000 |
| Subject: | Pear-DB - Oracle persistent connection | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-4087@lists.php.net to get a copy of this message | ||
I'm using PEAR-DB when connecting to an oracle database.
It works great, except it seems to be a lot slower than mysql. I guess the
reason is that I'm not using a permanent connection.
This is my code, but it didn't seem to work. Could anyone help me??
if(!isset($_SESSION['PEAR'])) {
#error_log("dev12 connecting to oracle database");
$user = 'username';
$pass = 'password';
$host = 'oracledatabase';
$db_name = 'oracledatabase'';
$dsn = "oci8://$user:$pass@$host";
$db = DB::connect($dsn, true);
// Alternatively: $db = DB::connect($dsn, true); // to get a persistent
connection...
// With DB::isError you can differentiate between an error or
// a valid connection.
if (DB::isError($db))
{
die ($db->getMessage());
}
session_start();
$_SESSION['PEAR'] = serialize($db);
}
// Otherwise, retrieve it from the session
else {
$db = unserialize($_SESSION['PEAR']);
}
Thank you!!
Alf Magne Kalleland