In Zend Framework 2 when I want to make a join between different database tables I have to use the \Zend\Db\Sql\TableIdentifier
class to avoid an incorrect escaping.
If I do in this way:
$select->join(['B' => 'database2.table2'], 'A.id = B.id');
It is rendered as:
SELECT [..] FROM "table" as "A" INNER JOIN "database2.table2" ON [...]
This causes an incorrect quoting "database2.table2"
To solve this situation I can do:
$tbl2 = new \Zend\Db\Sql\TableIdentifier('table2', 'database2');
$select->join(['B' => $tbl2], 'A.id = B.id');
In this way the quoting is correct "database2"."table2"
But how can I do if I have to specify the database and also the schema? (for example in ms sql server)
The desired result is "database2"."dbo"."table2"