0

I have two servers:

  • Server A: MySql
    • Table A
      • key-a
      • foreign-key-b
  • Server B: MsSql
    • Table B
      • key-b
      • foreign-key-a

Presumably I have two objects with methods that handle the relationships:

TableA->getRelatedTableB();

TableB->getRelatedTableA();

This is easy to implement in most ORMs. But what if I want to get a large set of objects with only one query per database server? Ideally the framework would abstract this and do the logical join so that the developer can pretend he doesn't know anything about the database(s). Something like:

FinderObject->getAlotOfTableAObjectsWithTableBAlreadyLoaded()

and it would perform a query on each database and logically join the results in some efficient manner.


Does anyone know of a way to implement this in Doctrine or some other php ORM framework?

4

3 回答 3

1

Doctrine 没有明确支持跨数据库连接,但有一种方法可以做到:

http://www.doctrine-project.org/blog/cross-database-joins

于 2009-07-27T18:29:42.290 回答
0

一种解决方案是使用federated tables,但我读到这并没有很好的性能。一切都取决于您需要如何使用它。

于 2009-07-27T17:57:46.710 回答
0

我不知道有什么……但也许你可以一起使用 Propel、Memcached 和 MySQL。使用 Memcached 设置分布式内存缓存,看看是否有办法在其中存储一些 MySQL 数据。因为 Memcached 是分布式的,所以您的两个 MySQL 服务器都可以在那里存储数据。然后你必须找到一种方法来访问该内存(通过内存表?)。似乎是一个非常棘手的情况。

也许是从错误的方向来处理问题。你能告诉我们你想解决什么问题吗?可能会有一个完全不同(而且更简单!)的解决方案指日可待。

于 2009-07-27T18:22:36.270 回答