?
Solved

Problem with Pear-DB - Persistent connection

Posted on 2003-03-07
2
Medium Priority
?
942 Views
Last Modified: 2012-06-21
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);

?>
0
Comment
Question by:Batalf
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 6

Accepted Solution

by:
carchitect earned 400 total points
ID: 8092922
if(!isset($_SESSION['PEAR'])) {


instead of using isset, use if_session_registered
regards
0
 
LVL 6

Expert Comment

by:carchitect
ID: 8588550
Thx
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question