Link to home
Start Free TrialLog in
Avatar of Batalf
BatalfFlag for United States of America

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['PEAR']);
}

// Use $db object any way you wish....

...

// Archive your class instance for the next page
$_SESSION['PEAR'] = serialize($db);

?>
ASKER CERTIFIED SOLUTION
Avatar of carchitect
carchitect

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of carchitect
carchitect

Thx