Let me get this straight. You are trying to do a join between two servers? Can you show us how you would do that in your database manager?
Jan 28, 2022
7
Level 1
defining 2nd database connection inside a query
so i have this query where i have to take joins between two tables in different databases Works fine for me on one server but not on another where it gives me a connection error so i'm trying to explicitly define connection inside the query is there any way i can do that?
$document_changes = DocumentChange::select([
"document_changes.id", "document_changes.doc_id", "changes", "document_changes.document_title", "document_changes.url", "document_changes.created_at", "document_changes.downloaded_doc_link"
])->where("document_changes.id", '>', 0);
if ($state_array[0] != "" || $vertical_array[0] != "" || $document_array[0] != "") {
// HEREEEEE
i wanna define 2nd connection name here like this connection2.database2.table1'
$document_changes = $document_changes->join('database2.table1', 'document_changes.doc_id', '=', 'database2.table1.id');
}
```
Please or to participate in this conversation.