CodeCharge Studio
search Register Login  

Web Reports

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

YesSoftware Forums -> CodeCharge Studio -> PHP

 change database connection

Print topic Send  topic

Author Message
erdcck


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
saseow

Posts: 744
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:
CCSetSession("host",$host);
CCSetSession("database_name",$database_name);
CCSetSession("port",$port);
CCSetSession("user",$user);
CCSetSession("password",$password);

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


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
saseow

Posts: 744
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 http://support.yessoftware.com.

PHP Reports

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

Home   |    Search   |    Members   |    Register   |    Login


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