开发者

How do you keep MVC with multiple databases?

I have lots of databases to hit and put in one page. Most of the frameworks only allow me two native configure them for one database. T开发者_运维技巧hey all assume the usage is for a new app and one database. I have lots of legacy databases.

Since I can only configure one database in frameworks I have seen ci, zend, others, it looks like my additional db connections have to take place in my controller.

What could I code on the back end to keep them out of the controller. I don't want to have to put in connection=myconn, etc. in each controller for each disparate database.

Also, are there any frameworks that allow for multiple databases in the ORM mapping?


I separate my controllers from my database with events. I fire some abstract "SaveWhateverComplicatedData" event from my controller, and a different class (who knows about all of my data storage specifics) listens for those events and interprets them. It's working quite well for me, and, though I only have one DB, I don't see any reason I couldn't have more.

This is a custom framework I've set up myself, but you could hook into another framework by wrapping these "data events" up in an interface that looks like a database. You could implement whatever interface your framework needs WITH the data events, and still have your listening multiple-database class doing the real work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜