20
I have the personal data (login, password, name, etc.) of the users on a different server than I will use in a new project. I would like to know how I can cross-reference information between two tables, from databases on different servers, with different login credentials as well. I intend to use only PDO / Mysqli resources to make these connections, since I use Shared hosts.
Example of what I wanted, in concept:
SELECT * FROM `serverLocal`.`banco`.`tabela`
INNER JOIN `serverRemoto`.`banco`.`tabela`
ON `serverLocal`.`banco`.`tabela`.`uniqid` = `serverRemoto`.`banco`.`tabela`.`uniqid`
WHERE `serverRemoto`.`banco`.`tabela`.`email` = '[email protected]';
In this example, the records relate through uniqid
'which are the same for lines with related content.
I thought about creating a REST API, but I don’t know how to use this information in a JOIN
, for example. How do you make this work? What other solutions would be relevant to solving this problem, and why? PDO / Mysqli already brings some native resource so you can "merge" two database connections into separate servers?
For example, sites like Stack Exchange, I believe that not everything is in the same server, but there is still the interaction between the sites of the network. Example: I am in Sopt, and when opening Soen, I am already logged in there too. There is cross-referencing of profile information, etc.
– Calebe Oliveira
Actually I wanted a way not to go out copying the same information in various databases of network servers, in this case, login information, for example.
– Calebe Oliveira
I may be wrong, but I don’t see this as good practice. You don’t have to replicate everything for every bank an app uses. But you can seek this information in other ways, such as the alternatives that Emerson Rocha Luiz cited.
– Andre Figueiredo