Reputation: 101
Is there any way to setup two database users in cake php? All read queries should use RO user and write queries should use RW user.
I am using mysql RDS and cakephp-2
Upvotes: 0
Views: 91
Reputation: 947
Yes, it is possible, but only by using two database definitions each associated with the specific user. It will be up to you to then make your models use one database or the other depending on which operation you are about to do; perhaps by writing the logic inside AppModel.php and have all you models extend only that class. (I have not tested this and the logic to switch database 'on-the-fly' may not work).
On the other hand, depending on what you are trying to achieve and your constraints, there may be a better solution when implementing this in your database rather than the application.
Upvotes: 1