简体   繁体   中英

Do any ORM frameworks support cross-database/cross-server joins?

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?

Doctrine doesn't explicitly support cross-database joins, but there is a way to do it:

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

One solution for this is to use federated tables , but I've read that this hasn't a good performance. All depends in how you need to use it.

I don't know of any that do... BUT maybe you could use Propel, Memcached, and MySQL together . Setup a distributed memory cache using Memcached, and see if there's a way to store some MySQL data in there. Because Memcached is distributed, both of your MySQL servers could store data there. Then you'd have to find a way to access that memory (via Memory Tables?). Seems a very tricky situation.

Perhaps the problem is being approached from the wrong direction. Could you tell us what problem you're trying to solve? There might be a completely different (and simpler!) solution just around the corner.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM