CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.

YesSoftware Forums -> CodeCharge Studio -> PHP

 change database connection

Print topic Send  topic

Author Message

Posts: 17
Posted: 07/28/2014, 11:11 PM

Dear friends

How can I change database connection after user logged

I added for every customers database connections in the ccs

I have 16 customers and 150 active user. I want to change database after user login for every customer.

Thank you so much.
View profile  Send private message

Posts: 735
Posted: 07/29/2014, 12:07 AM

I cannot imagine why you want to change the database connection for every user unles you have somehow created a different database for each user. Anyway...
In your Common.php set the database parameters to a session variable:
//Set up the default working database in this case 'local'
$CCConnectionSettings["local"]["Host"] = CCGetSession("host");
$CCConnectionSettings["local"]["Database"] = CCGetSession("database_name");
$CCConnectionSettings["local"]["Port"] = CCGetSession("port");
$CCConnectionSettings["local"]["User"] = CCGetSession("user");
$CCConnectionSettings["local"]["Password"] = CCGetSession("password");

Then, when a user logs in you can change the database by assigning the session vars:

Remember that they all have to login via the same table in the same database. Thats it.
View profile  Send private message

Posts: 17
Posted: 07/29/2014, 1:16 AM

Dear saseow thank you for your answer.
Actually I dont want to update changes for every customers files.
I want customers login project same url but use a different database. (sorry for my bad english)

Thank you so much
View profile  Send private message

Posts: 735
Posted: 07/29/2014, 8:15 AM

OK, then what I have given you will work just fine. Good luck with it and don't worry about your English! I don't know what your native language is but you speak english a lot better than I speak Xhosa! :(
View profile  Send private message

Add new topic Subscribe to topic   

These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.

Home   |    Search   |    Members   |    Register   |    Login

Powered by UltraApps Forum created with CodeCharge Studio
Copyright 2003-2004 by  and YesSoftware, Inc.