Home » Interview Question » Cake Php » How to use multiple database in cakephp

How to use multiple database in cakephp

How to use multiple database in cakephp

In This Tutorials we will explain how to use multiple database in cakephp application. Some times we are working with development and production both database for that without changing database name and other configuration manually, we define a connection string for each database in DATABASE_CONFIG class.

Step 1: You need to setup multiplae database string in your database configration file. open your app/Config/database.php file and set different database connection string. We have used two connection string.

Step 2: Now to access the data from diffrent database in same controller and same action. We use setDatasource function to call another database string which is set in your configration file(app/Config/database.php)

Your controller action would be look like as

, , , , , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">