RE: [phplib] database problem From: Brian Popp (bpopp <email protected>)
Date: 03/02/01

I didn't explain that very well.. let me try again..

If I have 2 different databases, I create 2 different DB_SQL classes:

class FIRST_DB extends DB_Sql <--- active_sessions is here
{
  var $Host = SERVER;
  var $Database = "First";
  var $User = USER;
  var $Password = PASSWORD;
}

class SECOND_DB extends DB_Sql
{
  var $Host = SERVER;
  var $Database = "Second";
  var $User = USER;
  var $Password = PASSWORD;
}

page_open( ..... )

$fdb = new FIRST_DB;
$sdb = new SECOND_DB;

$sdb->query ( "SELECT * FROM misc_table" );

// at this point, if you called page_close(), you would get an error
// because the database would still be set to SECOND_DB (which doesn't
// have an active_sessions table)

// Any valid query will work here just so long as it is quick. It's only
purpose
// is to change the database back to the correct db without using db
specific
// calls. Someone recommended using connect() here, but the phplib
documentation
// warns against it ("Link creation is implicit, there is no need to call
// connect() manually, EVER").

$fdb->query ( "SELECT sid from active_sessions WHERE sid='" . $sess->id .
"'" );

page_close ( );

Obviously this isn't actual code, so don't try copying and pasting it
without modification. Hopefully it's enough to illustrate what I am doing.
If not, feel free to email me and I'd be happy to elaborate further.

bpopp - bpopp.net

-----Original Message-----
From: John Mandeville [mailto:mandevil <email protected>]
Sent: Friday, March 02, 2001 2:15 PM
To: Phplib (E-mail)
Subject: Re: [phplib] database problem

Just to make sure I'm following this thread correctly: I $sessdb here
really $sess->db, or did I miss something?

On Fri, 2 Mar 2001 08:59:07 +0100, Marc Fournier wrote:
>
> Hello,
>
> > $sessdb->query ( "SELECT sid from active_sessions WHERE sid='" .
$sess->id .
> > "'" );
> I usually call $sessdb->connect(); just before page-close() to resolve
this
> problem, but as written in the phplib doc, you should try to integrate the
> session table in the same database as your application.

-- 
John Mandeville
mandevil <email protected>

--------------------------------------------------------------------- To unsubscribe, e-mail: phplib-unsubscribe <email protected> For additional commands, e-mail: phplib-help <email protected>

--------------------------------------------------------------------- To unsubscribe, e-mail: phplib-unsubscribe <email protected> For additional commands, e-mail: phplib-help <email protected>