[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Problem with Pear-DB - Persistent connection

Posted on 2003-03-07
2
Medium Priority
?
943 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
  • 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

640 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