Is there any real way to do a cross database join in a zf2 select statement? Ive been looking for a viable way to perform this without resorting to writing a full sql statement instead.
Currently my query looks somewhat like this:
$selectDB2 = $this->getSelect('db2.tabledb2');
$selectDB = $this->getSelect('field1');
$selectDB->join(
['tabledb2' => $selectDB2],
'tabledb1.id = tabledb2.id',
[],
$select::JOIN_LEFT. ' '. $select::JOIN_OUTER
);
After research I found that ZF2 does have issues: https://github.com/zendframework/zf2/issues/4307
The problem is the way that zf2 escape quotes, and a solution is listed. However, I was ideally after a way that would not involve having to modify the zf2 library itself, and also didnt require me to have to write one lengthy sql statement instead (as this isnt a viable option for the scope of this query).
Solved. ZF2's TableIdentifier gets around this problem very nicely. This resolves everything very cleanly and effectively.
$selectDB2 = $this->getSelect(new TableIdentifier('tabledb2', 'db2'));