Quantcast

[Cakephp3] Best way to change database on the fly by user

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Cakephp3] Best way to change database on the fly by user

Michał Piotrowski
Hello !

I used cakephp 3 to implement my apps and it's awesome :)

Now I try to implement datasource by user:
- one datasource by request
- every user can use diffrent database

 Now i used vars cache and read it after user login in tables static function defaultConnectionName this solution isn't brilliant but works.

Maybe you can give better solutions.



--
Sign up for our Newsletter for updates.
http://cakephp.org/newsletter/signup
 
We will soon be closing this Google Group. But don't worry, we have something better coming. Stay tuned for an updated from the CakePHP Team soon.
 
Like Us on FaceBook https://www.facebook.com/CakePHP
Follow us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Cakephp3] Best way to change database on the fly by user

rumble
You could bind a database with relation to your app.php and the datasources there, and based on param in url or some values in a table, execute in your controller:

ConnectionManager::alias($custom_db, 'default');

I am testing similar scenario, but on the model level. 


On Tuesday, February 23, 2016 at 11:20:38 PM UTC, Michał Piotrowski wrote:
Hello !

I used cakephp 3 to implement my apps and it's awesome :)

Now I try to implement datasource by user:
- one datasource by request
- every user can use diffrent database

 Now i used vars cache and read it after user login in tables static function defaultConnectionName this solution isn't brilliant but works.

Maybe you can give better solutions.



--
Sign up for our Newsletter for updates.
http://cakephp.org/newsletter/signup
 
We will soon be closing this Google Group. But don't worry, we have something better coming. Stay tuned for an updated from the CakePHP Team soon.
 
Like Us on FaceBook https://www.facebook.com/CakePHP
Follow us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Loading...