Setting variables in inherited model - 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: Setting variables in inherited model (/showthread.php?tid=27879) |
Setting variables in inherited model - El Forum - 02-23-2010 [eluser]Unknown[/eluser] I'm extending the core Model class to have a generic model I can use that includes basic get/set and database functions. As part of the new MY_Model I have created an array to hold field names and a __call to deal with get and set functionality. I would like to be able to set these field names up in new models that inherit the MY_Model but I suspect my scope (or at least ordering) is wrong. This doesn't work: Code: class MY_Model extends Model A print_r on $this->fields shows an empty array. A solution that works is as follow, but it seems a little kludgey Code: class MY_Model extends Model Is there a more elegant way of creating the required array keys? |