RE: [phplib] phplib and extra db access From: Ignatius Teo (iteo <email protected>)
Date: 01/16/01

Brian,

You can set the db handle to your phplib DB by setting up a subclass in local.inc like so:

class myCT_Sql extends CT_Sql {
  var $database_table = "active_sessions";
  var $database_class = "phplibDB";
}

class myDB extends DB_Sql {
  var $classname = 'myDB';
  var $Host = "localhost";
  var $Database = "anotherDB";
  var $User = "root";
  var $Password = "admin";
}

class phplibDB extends DB_Sql {
  var $classname = 'phplibDB';
  var $Host = "localhost";
  var $Database = "phplibDB";
  var $User = "root";
  var $Password = "admin";
}

Ignatius

> -----Original Message-----
> From: Brian Popp [mailto:bpopp <email protected>]
> Sent: Wednesday, 17 January 2001 04:35
> To: Phplib (E-mail)
> Subject: RE: [phplib] phplib and extra db access
>
>
> When doing this with PHPLib and MySQL, I've noticed that the database
> doesn't automatically get set back to the original
> authenticating database
> when calling page_close(). For example, if I do:
>
> $cb = new anotherDB;
> page_open (....);
> $cb->query ( "..." );
> page_close ();
>
> and anotherDB is a different db from the one used by the
> sessioning class, I
> get an error on page_close telling me that active_sessions
> doesn't exist in
> database anotherDB (or whatever it's called). I don't think
> phpLib's DB
> class allows you to manually change the DB, so I've been doing a :
>
> $db=authDB
> $db->query ("select id from active_sessions LIMIT 0,1");
> page_close();
>
> Admittedly not very elegant..but it works. If you've got an
> alternative,
> please post it here.
>
> BPopp - www.bpopp.net
>
>
>
> -----Original Message-----
> From: Max A. Derkachev [mailto:kot <email protected>]
> Sent: Monday, January 15, 2001 10:21 AM
> To: Miguel Dieckmann
> Cc: phplib mailingliste
> Subject: Re: [phplib] phplib and extra db access
>
>
> Hello Miguel,
>
> Monday, January 15, 2001, 5:32:55 PM, you wrote:
>
> MD> it works, but now the db-access of the chat system does
> not work. it's
> MD> another database. have the chat tables to be in the same
> database to
> work
> MD> together with the session management of phplib ?
>
> Not obligatory. But for each database you're using you should provide
> its own DB_Sql subclass.
> $db1 = new DB_1; // first db
> $db2 = new DB_2; // second db (e.g. for chat)
> Note that you'll have to provide different connection properties for
> each DB_* class (at least username and password should be different),
> cause php handles db connections in a strange way - if you want to
> make a connection to different databases, but use the same username
> and password, php reuses the first connection.
>
> --
> Best regards,
> Max A. Derkachev mailto:kot <email protected>
> Symbol-Plus Publishing Ltd.
> phone: +7 (812) 324-53-53
> http://www.Books.Ru -- All Books of Russia
>  
>
>
>
> ---------------------------------------------------------------------
> 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>
>