CodeIgniter Forums
Helper or Model for DB functions ? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Helper or Model for DB functions ? (/showthread.php?tid=51634)



Helper or Model for DB functions ? - El Forum - 05-11-2012

[eluser]ka-spot[/eluser]
I want to use functions like this:

Code:
function get_default_language()
{
    $CI =& get_instance();
    $CI->load->database();
    
    $CI->db->select('language')->from('languages')->where('default', 1);
    $get = $CI->db->get()->row();
    return $get->language;
}

inside different models like pages, products, categories, etc.
I'm learning CI while developing online store.


Currently i'm using helpers, but is it ok with the concept of MVC/CI?.

Wich one is better and why?


Helper or Model for DB functions ? - El Forum - 05-11-2012

[eluser]InsiteFX[/eluser]
If you are using the same methods over and over in different models then put them all in a helper!

Otherwise if they are just specific to that one model, then place them in that model.