Archive for database.php

CakePHP Database.php notes when using 2 or more databases

Posted in CakePHP with tags , , , , on February 16, 2009 by myleskadusale

If you will be using two or more database in your CakePHP webapp.  Be sure to take note of this.

In your database.php if you have more than one database setting be sure

to use different user accounts in each database to avoid problems because

in PHP if you are using the same account in accessing different database in the same server,

PHP will reuse the connection.  Thanks to AD7six for the info. 🙂

The problem I encountered was when I was using two database on the same server so I used same account for the two database.

Example:

Database1 . Table1   (Default DB to be used automatically by Cake)

Database2 . Table2

Now this two tables were associated,  I made a query to Table2 then I queried Table1 thats when the problem occured cake tried to query using Database2.Table1 which the correct location would be Database1.Table1

Advertisements