1

I am using codeigniter for developing application. My friend is using static method for loading models. is it good way to use or loader class ($this->load) works best?

I will show you how I am using it now.

in Controller:

    $this->arrUsrInfo['countries']  = Myloc_Model::getCountry( 0 );

    $this->load->view( 'add_Usrs', $this->arrUsrInfo );

In Model:

    $CI = get_instance();
    $CI->db->select('id, name');
    $CI->db->where('type', $intType );
    $CI->db->from('mylocationtable');
    $CI->db->order_by('name', 'asc');

    $objDbResult    = $CI->db->get();

This is simple project, so I can do this but if it is huge, I think it will be very hectic. Please help me which methid I should use, and also explain which method is best and how..Also provice me some links which you thing helpfull for me.

Ajinkya
  • 21
  • 6
  • 1
    It is generally a bad idea to use many static functions. There are many questions on SO covering this topic in detail. http://stackoverflow.com/questions/137975/what-is-so-bad-about-singletons – IROEGBU May 27 '15 at 07:15
  • 1
    [How Not To Kill Your Testability Using Statics](http://kunststube.net/static/) – deceze May 27 '15 at 07:31
  • How load feature in CI works? – Ajinkya May 29 '15 at 06:37

0 Answers0