[eluser]Unknown[/eluser]
Hi Folks,
I am very new to CodeIgniter and I had a question about best practices. I had an idea that it would perhaps be useful to have one generic model to parse data. I thought that it might be useful to create one generic model to reuse it again and again, but I am not sure if this is a violation of "MVC" principles or not.
Here's the code in my controller:
Code:
$data['holidays'] = $this->fetch_data->arFetch('cal','full_date',array('holiday'), array('holiday.cal_id = cal.id'),'');
Here's the code in my model:
Code:
function arFetch($table, $cols, $join, $joinOn, $where) {
$joinOn = array_combine($join, $joinOn);
foreach($joinOn as $t => $clause) {
$this->db->join($t, $clause);
}
#$this->db->where($where);
$q = $this->db->get($table);
if ($q->num_rows() > 0) {
return $q;
}
While I first thought this was a terrific idea, now I am not so sure. I almost feel as though I am using the model as a function, which does not seem to be the appropriate purpose.
Your thoughts would be greatly appreciated.
Thanks for the help everyone!
Kind Regards,
Tom G