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