postgres users authentication |
[eluser]XeRGi0[/eluser]
Hello there CI loverss... I have a lil' problem... I'm trying to implement an tiny authentication system, with DBMS users (postgre) instead of tables... I auto load the database library with a dbms superuser, 'cause i need it to make the validations, to do what i wanted i got to override default database configuration. The thing is, I made all the validations and stuff... the problem i have is when i'm trying to create a new connection (the new logged user information, such as username and password), it seems that is not creating the connection based on the new configuration i pass throw... I use a model, a controller and a view... Model: Code: <?php Controller: Code: <?php Plz Help! ![]()
[eluser]XeRGi0[/eluser]
Well people... I was all night trying to make this work... This is what i have so far... I have disabled the database autoload and make it all manually model by model, but I have another problem... I'll show you... My auth model, called by the controller, no big deal here... Code: function login($user, $pass) { So far it's everything ok, but when i tried to access one of my controllers... I get this error message: Quote:Fatal error: Call to a member function get() on a non-object in D:\Tools\apps\DESARROLLO\system\application\models\categorias_model.php on line 26 I only load the database class in the model, my controller only calls that function and show the data.. So that's way i don't understand why i get that error... This is my model: Code: <?php Again.. Plz Help!
[eluser]Pascal Kriete[/eluser]
I assume you read the section on connecting to multiple databases here. When you use the normal loading call, the database is attached to the CI super object as $db. Code: $this->load->database(); // no third parameter But when you pass in that third parameter, the database object is returned instead of being tied to $db. So you would do: Code: $DB = this->load->database($dns, NULL, TRUE); If you need it for more than one method, you will want it as a class variable. Try this: Code: Class Categorias_model extends Model { Hope that helps.
[eluser]XeRGi0[/eluser]
It works, but it wasn't the third parameter, it was the second, the third is to set the active record to true... I set the second parameter to TRUE and make the changes you told me and works... I didn't get the whole idea of using multiples databases, 'cause i wasn't using multiple databases, i just wanted to change the connection information (user and password). Know... If I assign a new connection for every model I have... won't overload my dbms? All the other connections will be open? I think CI is not that flexible to work with this type of authentication... I think is better in case you want to prevent user to access to certain tables, you make all the validations in the dbms, and let him do the job for you... Going back to my first question on this thread... Is there a way to override the database configuration? To avoid the calling to the database class for every single model? Thanx for your response |
Welcome Guest, Not a member yet? Register Sign In |