This topic is locked

Using Multiple Datagases

12/5/2009 4:01:15 PM
PHPRunner General questions
L
lewisekrantz author

Is there a way to use a different database for different users ??

Pfeiffer 12/6/2009

Hello,
try the following :

  1. User has to pass the database by parameter in login-page

    for example the link is .....login.php?database=XX
  2. Use AfterApplicationInitialized event an insert the following code :
    if ( postvalue("Datenbank")) $sys_dbname = $_SESSION["Database"];

    else die ("Parameter for database is missing.");
    in $sys_dbname is the actual database stored.
    I didn't try it (was a tip from support to my question) so please let me know the result...
    Best regards

    Uwe Pfeiffer

L
lewisekrantz author 12/6/2009



Hello,
try the following :

  1. User has to pass the database by parameter in login-page

    for example the link is .....login.php?database=XX
  2. Use AfterApplicationInitialized event an insert the following code :
    if ( postvalue("Datenbank")) $sys_dbname = $_SESSION["Database"];

    else die ("Parameter for database is missing.");
    in $sys_dbname is the actual database stored.
    LK: That rally won't quite do it because you still have to pass whatever is in dbcommon.php I think.

    Things like name of host (localhost or ???) username to the database, password to the database.

    Essentially you would need the info in dbcommon.
    I dont know if the dbcommon variables are called on everypage or they are session variables. If they are session variables there are some ways I can think of to do it by storing the database information in the user record

    or something to that extent
    I didn't try it (was a tip from support to my question) so please let me know the result...
    Best regards

    Uwe Pfeiffer

L
lewisekrantz author 12/6/2009



Is there a way to use a different database for different users ??


I checked .... looks like dbcommon.php is called at the beginning of each page ... So I would need a different strategy.
Perhaps multiple dbcommons with diff somehow tied to the user name or something like that ...
Will post a solution when I figure it out
LK

Pfeiffer 12/6/2009

Hello,
I thought you only wanted to change the database..and not the connection to database.

I have a PHPRUNNER program used by different customers. The connection ist the same mysql string, but

my customers have different databases inside the same MYSQL.
sys_dbname ist used as global variable as you can see in db_connection - function.
At first PHPRunner starts with the defined connection you used during application development.

Then the database is changed throug the parameter.
Perhaps I misunderstood your question..
Best regards

Uwe Pfeiffer

L
lewisekrantz author 12/6/2009



Hello,
I thought you only wanted to change the database..and not the connection to database.

I have a PHPRUNNER program used by different customers. The connection ist the same mysql string, but

my customers have different databases inside the same MYSQL.
sys_dbname ist used as global variable as you can see in db_connection - function.
At first PHPRunner starts with the defined connection you used during application development.

Then the database is changed throug the parameter.
Perhaps I misunderstood your question..
Best regards

Uwe Pfeiffer


I think your solution is the best one. I have user permissions on MySql to particular Databases within MySql. Sounds like you have a Master User with full permissions to all Databases with MySql. If my understanding of the way you are doing it, I like your way.

That way the user & Pw and Host name or IP do not change. Is that correct ??
To save me a bit of time in figuring it out , when is the db_connection function called ... (a) Once at program startup or (<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=45964&image=1&table=forumreplies' class='bbc_emoticon' alt='B)' /> ???