推动 ORM 并发连接
我正在使用 Propel ORM 开发一个项目,需要连接到两个不同的数据库来检索某些数据。我尝试在网上搜索指南,但没有运气,因为所有“解决方案”要么特定于 Symphony,要么根本不起作用。
我希望能够指定两个连接,并能够通过向查询传递连接别名来在某些查询期间在它们之间进行切换。但是,同时打开两个连接也是可以接受的。
非常感谢任何和所有的帮助!
谢谢, 迪马
I am working on a project using Propel ORM and need to connect to two different databases to retrieve certain data. I've attempted searching online for a guide, but had no luck as all the "solutions" were either specific to Symphony or just simply did not work.
I would like to be able to have two connections specified and be able to switch between them during certain queries by passing a connection alias to the query. However, it is also acceptable to have both connections open simultaneously.
Any and all help is greatly appreciated!
Thanks,
Dima
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据 Propel API 文档,您可以在架构中定义数据库连接.xml 文件以这种方式:
然后在您的 runtime-conf.xml 设置,您可以设置连接参数:
-- 编辑 --
似乎 Propel 不支持数据库标签的别名属性,但您应该能够获得放弃以下内容:
看看是否有效。归根结底,真正重要的是可以与两个数据库建立连接(使用各自的 DSN)。
According to the Propel API Docs you can define a database connection in your schema.xml file in such a manner:
Then in your runtime-conf.xml settings you can set the connection params:
-- Edit --
Doesn't appear that Propel supports an alias attribute for the database tag, but you should be able to get away with the following:
See if that works. At the end of the day the thing that really matters is that a connection can be made to both databases (using respective DSNs).