Extending a model that extends MY_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: Extending a model that extends MY_Model (/showthread.php?tid=49233) |
Extending a model that extends MY_Model - El Forum - 02-12-2012 [eluser]Rob Corley[/eluser] I'm getting the following error:- Code: Fatal error: Call to undefined method Some_model::method() method() is defined in my extension to CI_Model (MY_Model). Some_model extends Version_model and Version_model extends MY_Model. I am autoloading Version_model and I can call methods that are defined in Version_model, but not one's defined in MY_model. This doesn't happen if I inherit directly from MY_Model. Here's the code to clarify my explanation; Extension to CI_Model:- Code: class MY_Model extends CI_Model { Version model which handles record versioning:- Code: class Version_model extends MY_Model { The model that extends Version_model and the one that is producing the error:- Code: class Some_model extends Version_model { To produce error:- Code: class Some_controller extends CI_Controller { This produces the following error:- Fatal error: Call to undefined method Some_model::method() in ... Thanks in advance, I feel like I'm just missing something obvious... Extending a model that extends MY_Model - El Forum - 02-12-2012 [eluser]mah0001[/eluser] You need to place your MY_Model class in the CORE folder instead of the LIBRARIES folder. Extending a model that extends MY_Model - El Forum - 02-12-2012 [eluser]Rob Corley[/eluser] Thank you very much! I had already discovered this, but instead of moving the file I had copied it so I had MY_model in core and libraries and it was the lib one I was adding this new method to! Thanks again! |