CodeIgniter Forums
Connect to database with different credential for different user? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: Connect to database with different credential for different user? (/showthread.php?tid=68551)



Connect to database with different credential for different user? - avinash - 07-25-2017

Hi,
  First I'm beginner for CodeIgniter. Iam trying codeigniter for a new project.


In my site, there are three level of user.  Each user level have access to the certain tables in the database. If I use CodeIgniter for my project, How to connect with different Database credential when a user logged in?


RE: Connect to database with different credential for different user? - qury - 07-26-2017

If i would be in a similar situation i would use the default db connection for administrative tasks (get global settings, user profile).

Then i would use a the user specific db connection to access other functions. Check the "Connecting to Multiple Databases" and "Manually Connecting to a Database" section in the guide.