Closed ellisgl closed 4 years ago
I don't think so. Based on my experience you can only use one database inside a request. You can define multiple connections but these are just datasources, not cross-db references.
Last time I checked PDO didn't allow it.
@merry-goblin Why wouldn't PDO allow it? FKs are DB side and PDO shouldn't have a reason to know about them, since it's basically just a query passer.
@FlipEverything So, no queries like this are generated:
SELECT t1.*, t2.*
FROM db1.table t1
INNER JOIN db2.table ON t1.id = t2.someId;
No, joins are not supported right now (#175).
The Query Builder is bound to the default connection which (I think) is bound to a single database. https://github.com/spotorm/spot2/blob/70f5d92594f9c8f03f03b1dbf4737225740c80ff/lib/Query.php#L112-L113
If you are using Spot elsewhere in your application, you can also write raw SQL queries in Spot and still populate collections and entities with the results, but Spot itself may not directly support this use case.
Say I have system where I have a couple main DBs (let's say they are called 'main', 'a', 'b', 'c') and I have a bunch of DB that are segmented for customer data, but their structures are all the same (let say they are named 'cust-1', 'cust-2' ... 'cust-n'). These DBs are all in the same server. Now there can be FKs that could be make in the structures that point to the other DBs (which is totally doable in MySQL / Maria and several others). Is this achievable in Spot?