Closed kaltar closed 14 years ago
ManyToMany relationships just aren't written to support relationships across databases. Yes in 8some8 case it is possible to do cross database joins assuming a certain DB driver, and that both DBs are n the same database host but trying to code around all the cases where this won't work would be massively complex.
I feel this is such an edge case that it doesn't warrant change to the core - if you really need this behaviour it is relatively easy to implement for a specific case by extending the relationship field class. Solving it generally is going to be nearly impossible and not worth the effort.
In fact it is pretty hit or miss whether any relationship types would work out of the box between models on different databases. This is very hard to code generally in an efficient way and if you do genuinely have data split across machines, I'm guessing your application is big enough to warrant a little customisation work to make the relationships behave efficiently and exactly as you need.
Cool. No Problem :) I just think that those things should be documented (The things Jelly can't do). So far, I LOOOOOVE Jelly, and the ability to specify the DB in the model make me thought every kind of magic is possible. Now I see is only awesome Magic :)
Thanks Banks.
Even when using $meta->db() in different models, it generates a query trying to read the the tables from the foreign model, and not respecting the pivot table DB:
//this model uses DB1 'ports' => new Field_ManyToMany(array( 'foreign' => 'unlocode', // this model has DB2 'through' => array( 'model' => 'pivot', // This model has DB1 'columns' => array('id1', 'id2'), ), )),
In this example, I always get the error query that table pivot is not existing in DB2!