At work by inheritance got 6 applications for php + Codeigniter + DB mySql. Each database contains tables (directories) that are repeated in these databases in different combinations. For example, tables of standards, products, users, etc. Periodically there is a need to update the data in these directories and this process is very tedious, finding where these tables are repeated and updated. Now I am writing another program and I will also need to use some tables there (reference books).

In the beginning, I thought of creating a database as a single database for such tables (reference books). Then it would be possible to update once from other applications to access this database, But I did not find how to make a simultaneous request in codeigniter to two different databases (combine tables from different databases). I just can't figure out how else to organize the update of such tables in different databases. Maybe someone has experience in the implementation of this, please share.

    1 answer 1

    Usually in MySQL, when accessing a table from another database, the prefix is ​​simply used - the name of this database.

    SELECT tbl.name FROM other_db.my_table tbl WHERE tbl.id = 100 
    • @EugeneOleynikov And table names are not used there? The request is not performed by Codeigniter, but by MySQL. Codeigniter request just sends - Anton Shchyrov
    • @EugeneOleynikov Have you tried to specify the name of the table with the name of the base, or are you just theorizing? - Anton Shchyrov
    • Yes, it really works. Although I was sure that it does not work. It seems even tried before. - Eugene Oleynikov
    • @EugeneOleynikov If my answer is correct, then mark it as correct - Anton Shchyrov