Batalf
asked on
Problem with Pear-DB - Persistent connection
I'm using Pear-DB while connecting to Oracle. But the code following code doesn't give me a persistent connection. What's wrong?
<?php
// Define the class anyway
require_once 'DB.php';
// Start your session
session_start();
// Check whether the session is archived
// If nothing is memorized, do it for the first time:
if(!isset($_SESSION['PEAR' ])) {
$user = 'myuser';
$pass = 'mypassword';
$host = 'myhost.domain.no';
$db_name = 'myhost.domain.no;
$dsn = "oci8://$user:$pass@$host" ;
$db = DB::connect($dsn, True);
}
// Otherwise, retrieve it from the session
else {
$db = unserialize($_SESSION['PEA R']);
}
// Use $db object any way you wish....
...
// Archive your class instance for the next page
$_SESSION['PEAR'] = serialize($db);
?>
<?php
// Define the class anyway
require_once 'DB.php';
// Start your session
session_start();
// Check whether the session is archived
// If nothing is memorized, do it for the first time:
if(!isset($_SESSION['PEAR'
$user = 'myuser';
$pass = 'mypassword';
$host = 'myhost.domain.no';
$db_name = 'myhost.domain.no;
$dsn = "oci8://$user:$pass@$host"
$db = DB::connect($dsn, True);
}
// Otherwise, retrieve it from the session
else {
$db = unserialize($_SESSION['PEA
}
// Use $db object any way you wish....
...
// Archive your class instance for the next page
$_SESSION['PEAR'] = serialize($db);
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Thx