Need an idea on how to set $db dynamically |
[eluser]duartix[/eluser]
Cheers. I've got the need to connect to Oracle and I intend to use the database authentication as a connection validator. My connection needs to be so dynamic that the user will provide username, password and sid. I've been struggling with several approaches the first would be setting those values for $db within a controller/model along these lines: Code: $db['oracle']['username'] = $this->session->userdata('username')); The first problem is that there is no direct access to $db within either the controllers or the models. I've tried several approaches (between controller and model) and the last I thought that could sort it would be by doing something like this (never mind the 'sid" parameter right now): Model Code: public function login() { The code does not work. On the third line, when I try to set the first variable ('username') it will give me: Quote:Fatal error: Call to a member function set() on a non-object in C:\xampp\htdocs\glup2\application\models\security_model.php I'm getting the feeling that I'm probably confusing db objects with dbdriver objects and that's just the beginning because I can't shake the feeling that this might turn into a chicken and egg situation, where I can't set those parameters without having the database object first, but then as it's loaded it's too late to change the database settings... Is this the right approach and I just need to get my object types and scope sorted out, or should I address the configuration file application/config/database.php directly and make it dynamic over there? Maybe like this? http://stackoverflow.com/questions/16515...odeigniter Thanks in advance.
[eluser]duartix[/eluser]
Do you think a better approach to ignore database.php altogether and build all the configuration manually, as pointed here: http://ellislab.com/codeigniter/user-gui...cting.html Am I loosing any driver faculties/features if I do it manually?
[eluser]duartix[/eluser]
Sorted! I broke into database.php and did it manually like so: Code: $CI =& get_instance(); The connection information is filled through session variables that are easily accessible in both models and controllers. So much time wasted, but at least the solution seems simple and clean. |
Welcome Guest, Not a member yet? Register Sign In |