We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

join between two databases

Hey,

i've two databases and want to make a join between this. But when i try to get the Data, i'll become an error:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'db1.TABLE2' doesn't exist

But TABLE2 is not in db1, it is in db2. The Models exists and the TABLE2 has in the Initialize-Function $this->setConnectionService('db2'); (db2 links on the Database in the ConnectionService)

What can i do to get Data from Tables in different Databases.

Retrieving data from 2 separate databases in 1 query is pretty rare, so I don't think either PHQL or the ORM are set up to handle it. You can with raw SQL though.