views:

246

answers:

4

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?

A: 

This should help answer your question:

http://en.wikipedia.org/wiki/Comparison_of_web_application_frameworks#Comparison_of_features

Tom
What I'm referring to is a rather advanced (uncommon) use case and is not prominently advertised by any framework I've come across.Thank you for your answer.
Yeah, this is a pretty unique use case that I do not have the answer to. Good luck!
Tom
A: 

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.

Gabriel Sosa
A: 

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.

lo_fye
Your approach sounds interesting, though I've never used memcached so I couldn't really speak to how feasible it would be.I am writing an application that needs data from two databases that exist on two different physical servers using different database systems (mysql, mssql). I should mention that I don't 'own' the databases and therefore cannot alter or move them.I've considered an approach where I batch process the data to aggregate it into some third data store local to where my application would run. Not out of the question, but it does introduce concerns about the data going stale.
Not owning the DBs certainly does make it tricky. You might look into parsing the replication files, and inserting them all into your own 3rd database that contains both datasets. Will be a maintenance nightmare though, as schemas change. Best of luck!
lo_fye
A: 

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

Jordan Ryan Moore
I've seen that article... pretty cool stuff. Unfortunately it's not quite applicable. They are referring to cross database joins where the multiple databases are on the same RDBMS. In my case the databases are on different physical servers using different database systems (mysql, mssql). Thanks for your response!