I haven't tested it, but I would expect that duplicating the externaldb_* nodes under global\resources with another (unique) resource name e.g. externaldb2_* should work.
You can specify the resource used in the module's etc/config.xml file, so that a module will always use a certain data source or you can specify in the global config xml as described by the previous answer, then this connection will be used by default.
As far as I can tell, you can't have models connecting to multiple database sources from within the same module.
What I've done, is create a parallel dummy module, that only contains the model that needs to connect to the alternate database. So the module that does all the work is in one branch, and the dummy module to talk to the other database is separate. Solves the problem beautifully, although it's not the most elegant solution... but it's not the least elegant either
发布评论
评论(4)
我还没有测试过它,但我希望将
global\resources
下的externaldb_*
节点复制为另一个(唯一的)资源名称,例如externaldb2_*
代码>应该可以工作。I haven't tested it, but I would expect that duplicating the
externaldb_*
nodes underglobal\resources
with another (unique) resource name e.g.externaldb2_*
should work.您可以在模块的 etc/config.xml 文件中指定使用的资源,以便模块始终使用某个数据源,或者您可以按照前面的答案在全局配置 xml 中指定,然后该连接将被使用默认。
您可以更改代码中的资源:
You can specify the resource used in the module's etc/config.xml file, so that a module will always use a certain data source or you can specify in the global config xml as described by the previous answer, then this connection will be used by default.
You can change the resource in your code:
我发现这个 Magento 模块将有助于连接到外部数据库系统。 http://subesh.com。 np/2012/02/magento-external-database-connector-v1-0-0-released/
我尝试了该模块,似乎运行良好。希望这会有所帮助。
编辑:
模块也可在 Magento Connect 上使用。 http://www.magentocommerce.com/magento-connect/sp-edb -4574.html
I found this one Magento Module that will help to connect to external database system. http://subesh.com.np/2012/02/magento-external-database-connector-v1-0-0-released/
I tried the module and seems to be working well.Hope this helps.
EDIT:
Module also available on Magento Connect. http://www.magentocommerce.com/magento-connect/sp-edb-4574.html
据我所知,您不能让模型从同一模块内连接到多个数据库源。
我所做的是创建一个并行虚拟模块,该模块仅包含需要连接到备用数据库的模型。因此,完成所有工作的模块位于一个分支中,而与其他数据库通信的虚拟模块是单独的。完美地解决了问题,虽然它不是最优雅的解决方案......但它也不是最不优雅的
As far as I can tell, you can't have models connecting to multiple database sources from within the same module.
What I've done, is create a parallel dummy module, that only contains the model that needs to connect to the alternate database. So the module that does all the work is in one branch, and the dummy module to talk to the other database is separate. Solves the problem beautifully, although it's not the most elegant solution... but it's not the least elegant either