0

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 connection Commented 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. Commented Aug 24, 2017 at 10:57
  • have a look at this question stackoverflow.com/questions/30262176/… Commented Aug 24, 2017 at 10:58
  • this is fine but not great Commented 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 needed Commented Aug 24, 2017 at 11:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.