• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
best practise loading in model $this vs get_instance()

#1
[eluser]jof[/eluser]
Hi all

I have a newbe question. In models I kan load for example a helper like this

Code:
$this->load->helper('email');

Or I can do it like this, and first grab the ci object by ref and then...

Code:
$this->ci =& get_instance();
$this->ci->load->helper('email');

the same seems to work for sessions.

Code:
$this->session->set_userdata('id', 100);

Code:
$this->ci =& get_instance();
$this->ci->session->set_userdata('id', 100);

What is the "correct way" to do this?

In some code I have seen the 'get_instance' is used in models, but that seems not to be necessary?


regards // Johannes


Messages In This Thread
best practise loading in model $this vs get_instance() - by El Forum - 09-20-2009, 01:46 PM
best practise loading in model $this vs get_instance() - by El Forum - 09-20-2009, 02:54 PM
best practise loading in model $this vs get_instance() - by El Forum - 09-20-2009, 02:56 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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