如何将模型与 Zend Framework 的 multidb 中的特定数据库适配器链接

发布于 2024-10-04 09:05:45 字数 234 浏览 0 评论 0原文

该应用程序最初使用单个数据库,但现在我正在更改它,以便不同的数据组位于不同的数据库中。我使用 multidb 添加了另一个数据库。现在某些模型正在使用非默认数据库,但我不知道如何强制模型始终使用特定适配器。在与模型交互之前,我尝试使用 Zend_Db_Table::setDefaultAdapter 更改适配器,但现在我必须更改所有模型的所有功能,以确保模型与正确的适配器交互。有没有更简单的方法来实现它们。我的模型扩展了 Zend_Db_table。

The application was initially using single database, but now I am changing it so different groups of data sits in different database. I added the other database using multidb. Now some model's are using non-default database, but I don't know how to force a model to use specific adapter all the time. I tried changing the adapter by using Zend_Db_Table::setDefaultAdapter before interacting with models, but now I have to change all function of all models, to make sure the model is interacting with the right adapter. Is there any simpler way of achieving them. My model's extend Zend_Db_table.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鱼窥荷 2024-10-11 09:05:45

这应该可以帮助你:
http://jameshd.wordpress.com/2010/09/27/ zend-multi-db/

有了一些基本的扩展和每个模型要使用的数据库适配器的设置,您应该就可以开始了。

This should help you out:
http://jameshd.wordpress.com/2010/09/27/zend-multi-db/

With some basic extensions and a per-model setting of what database adapter to use, you should be good to go.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文