• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using Classes in Helper files?

#1
[eluser]Iverson[/eluser]
I'm using CI's database class in my controllers. I have a "is_logged_in" function that I will have to use in every controller/view so I created my own helper file because I don't want to have to copy and paste it over and over again. I check the session footprint against the footprint I put into my database. However, now I have no way of getting to the database or the session data because I can't use the class functions inside a regular function. Ideas? Or am I just missing something?

#2
[eluser]Yash[/eluser]
Just use model.

Create a function in a model. Check session or do whatever you want. like redirecting to login form if not logged and so on...

Now access this function in controller functions.

I like this way..You can decide your own.

#3
[eluser]Iverson[/eluser]
You know what? I was wondering if that's what models were for. I've only been using CI for about 2 weeks. I've found MVC to be quite useful. However I've only gotten to play with the V's and C's so far...lol. Thanks!

#4
[eluser]Yash[/eluser]
Models are very easy to use.Just do one thing read user guide carefully then you will ask less Qs and code more.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.