RE: [phplib] Multiple Schemas From: Brian Popp (bpopp <email protected>)
Date: 06/29/01

Personally, I prefer to create a separate local.inc type file for each
project. I never use the general local.inc. This is how I setup all my
projects and it seems to work pretty well. I create a file called
globals.php. This file declares any project specific variables. Here's an
example:

        define ( "DB_SERVER", "localhost" );
        define ( "DB_USER", "db" );
        define ( "DB_PASSWORD", "secret" );

        define ( "DATABASE", "home" );
        define ( "SESSION", "csession" );
        
        define ( "HTTP_SERVER", "www.bpopp.net" );

        define ( "RELATIVE_ROOT", "/dev/www/" );
        define ( "ABSOLUTE_ROOT", "/home/httpd/html/dev/www/" );

        include ( ABSOLUTE_ROOT . "auth.php" );
        include ( ABSOLUTE_ROOT . "common.php" );

Next I create the auth.php file, which is basically a declaration of my
sess, auth, db, and user classes (similar to local.inc). Note that the
auth.php file references the above globals so that it can easily be moved
between projects with minimum modification. My auth.php file also has a
function called my_page_open() and my_page_close() that does project
specific page_open/page_close calls.

A typical project file would look like:

        include "../globals.php";
        my_page_open();
        
        ....

        my_page_close();

The file "common.php" is where I put any project scoped functions.

If there are any 'tragic' flaws with this method, please don't tell me
because ignorance is bliss and it has worked VERY well for me. If you have
any questions, drop me a note.

BPopp - bpopp.net

-----Original Message-----
From: nathan r. hruby [mailto:nathan <email protected>]
Sent: Friday, June 29, 2001 8:48 AM
To: White, Bob
Cc: 'phplib <email protected>'
Subject: Re: [phplib] Multiple Schemas

On Fri, 29 Jun 2001, White, Bob wrote:

> Hi All,
> I am looking for suggestions for setting up multiple schemas using PHP4,
> phplib , Apache, Oracle 8.1.6. Here is the scenario. I would like to
have
> separate tables for each user (project) I would like to have a universal
> set of php scripts that accessed the same tables under different projects.
> Can I have multiple instances of DB_Sql open at the same time? Can they
> both be declared in local.inc? How is this normally done?
>

Yes, just make a new subclass of DB_Sql for each project that you have.

class Project1DB extends DB_Sql {

   var $classname ="Project1DB";
   var $Host = "localhost";
   var $Database = "project1";
   var $User = "project1";
   var $Password = "project1";
}

class Project2DB extends DB_Sql {

   var $classname = "Project2DB";
   var $Host = "localhost";
   var $Database = "project2";
   var $User = "project2";
   var $Password = "project2";
}

Then in your script just do:

$p1db = new Project1DB;
$p2db = new Project2DB;

Remember the if there are diffrent databases, and you plan on ussing
Session that each db should have seperate username / password pairs or php
will reuse the last connection and Session stuff will fail during
page_close().

-n

-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
nathan hruby / digital statement
nathan <email protected>
http://www.dstatement.com/

Public GPG key can be found at: http://www.dstatement.com/nathan-gpg-key.txt ED54 9A5E 132D BD01 9103 EEF3 E1B9 4738 EC90 801B -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

--------------------------------------------------------------------- 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>