Librairy vs model vs helper best place for authentification function ? |
[eluser]Rushino[/eluser]
Hello, For an authentification function that check login credentials, what would be the best place to put it ? What the main differences of each because this is a bit confusig. Thanks!
[eluser]Eric Barnes[/eluser]
I typically use a library and a few helpers to handle my auth. The library logs them in, verifies, etc. Then a helper is just for things like: is_logged_in() so I can have conditionals in the views.
[eluser]Rushino[/eluser]
So there no problems in using models in a library ? Or should i use db function without the model directly in th lib ? (just looking for best practice)
[eluser]Eric Barnes[/eluser]
My take on it is the db stuff can either be in the library or moved to a model. The beauty of CodeIgniter is that you can do things that may not be "recommended" but it still works just fine. Take a look at this three part tutorial which should help you out and get you up to speed: http://www.gregaker.net/2010/dec/06/crea..._part_one/
[eluser]InsiteFX[/eluser]
You can load models in library, but for libraries you will need to the CI Super Object! Code: class library { InsiteFX
[eluser]toopay[/eluser]
typo! Code: // too much 'n' and NO CODE! ;-P
[eluser]InsiteFX[/eluser]
Fixed thanks, my keyboard sticks on some keys some time repeating them. Guess it's time to replace it LOL InsiteFX
[eluser]Rushino[/eluser]
I think i will do as you suggested InsiteFX. The reason is that i do not want to repeater DB functions in my lib if they are available in the model that wouldnt be smart. So i will use that CI super object afterall lol |
Welcome Guest, Not a member yet? Register Sign In |