xpdo
xpdo copied to clipboard
[Feature Request] - Support models from alternate database
It would be great if xPDO allowed working with models from an alternate database.
Today, if you want to work with addPackage()
using a model stored in an alternate database, one way to accomplish this is to setup a secondary (or 3rd, or 4th...) xPDO connection.
Example: https://rtfm.modx.com/extras/revo/cmpgenerator/cmpgenerator.foreign-databases
However, this is an inefficient way of attempting to access a table in an alternate database if it is already on the same server and the current connection's user has proper access permissions.
If there was a way for individual packages to override the database to use, it would open up new opportunities, or at the very least, become more efficient in some scenarios.
The best workaround I have found so far is to leverage a View:
CREATE VIEW local_db.custom_table AS SELECT * FROM foreign_db.custom_table;
@opengeek in your experience, would you envision support for this feature a "large undertaking," or could someone less-versed in xPDO potentially assist?
I'm happy to contribute a working PR, but wondering if you could provide some recommendation on a starting point?