-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
union-query on multiple databases #17353
Comments
ok seems thats basically not supported. Only with hacks :( |
We don't support joins/unions across databases. Database connections could be in different physical machines and there is no way for the ORM to safely abstract operations across databases. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
Tried to create a union query on two tables that are on different databases and get an error.
It does not seem to take into account the other DB prefix.
simplified Example:
CatsTable on DB cats.
DogsTable on DB dogs.
I did define the DB name in each Table with defaultConnectionName():
I can successfully query the tables individually.
Now I want to do a union query.
$catQuery = $this->fetchTable('Cats')->find()->order(['created'])->limit(10);
$dogQuery = $this->fetchTable('Dogs')->find()->order(['created'])->limit(10);
$query = $catQuery->unionAll($dogQuery)->order(['created'])->limit(10);
I get this error:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'catsDb.dogsTable' doesn't exist.
CakePHP Version
4.4.18
PHP Version
8.1
The text was updated successfully, but these errors were encountered: