I have a table that contains all database name. I want to create a run time database connection in CakePHP and search data in the database. Is there any way in CakePHP to fetch database name from default database and create runtime connection?
7
-
Don't know if this helps $this->db = & ConnectionManager::getDataSource('default'); in controller and then use this connectionKeyur Padalia– Keyur Padalia2017-08-24 10:51:11 +00:00Commented Aug 24, 2017 at 10:51
-
Hi Keyur, thank you but i have a table that contain all database name . condition is that i want to search something .if it is found in first database than no need of second connection otherwise need to create connection with second database.Sourabh Devera– Sourabh Devera2017-08-24 10:57:19 +00:00Commented Aug 24, 2017 at 10:57
-
have a look at this question stackoverflow.com/questions/30262176/…Keyur Padalia– Keyur Padalia2017-08-24 10:58:58 +00:00Commented Aug 24, 2017 at 10:58
-
this is fine but not greatSourabh Devera– Sourabh Devera2017-08-24 11:45:56 +00:00Commented Aug 24, 2017 at 11:45
-
If you have a finite number of databases then I think you could create that many connections in app/config.php and then use them on fly as neededKeyur Padalia– Keyur Padalia2017-08-24 11:47:27 +00:00Commented Aug 24, 2017 at 11:47
|
Show 2 more comments