CodeIgniter Forums
Multi-database Project - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: Multi-database Project (/thread-70000.html)



Multi-database Project - VigoKrumins - 02-07-2018

Hello CodeIgniter gurus!

Currently, I have two separated same projects only using different databases. When ever I do changes in the code, I've to update it on both projects which is a little bit a pain in the back.

I've an idea create a single project but using 3 (or more, depends on clients) databases.

1st database - MASTER DB.
This database has users table, clients table (with information about other databases, etc).

2nd database - Client One && 3rd database - Client Two
Structure in both databases are the same only different data.

P.S I can't merge 2nd and 3rd database into one database because I've created a web application for already existing system.

What would be the best way to do this?
I can create an authorization system which takes data from MASTER database. When user log-in, it saves in sessions which database it should work with. How to handle this multi-database problem? I should create my own Database model or what? :?

If you've any questions, feel free to ask.

Thanks,
Vigo


RE: Multi-database Project - php_rocs - 02-07-2018

@VigoKrumins

Maybe this is what you are looking for ( https://codeigniter.com/user_guide/database/connecting.html?highlight=database#connecting-to-multiple-databases )?