CodeIgniter 2 can't extend CI_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: CodeIgniter 2 can't extend CI_Model (/showthread.php?tid=32862) |
CodeIgniter 2 can't extend CI_Model - El Forum - 08-07-2010 [eluser]Rui Lima[/eluser] Hello, I'm trying to extend CI_Model, but am unable to do it. Code: class MY_Model extends CI_Model{ then when it gives me error: Quote:Fatal error: Class 'MY_Model' not found in Code: class User_Model extends MY_Model{ //<--- can't fund MY_Model Any ideas? (this is CodeIgniter 2.0, i was able to do this with 1.7) CodeIgniter 2 can't extend CI_Model - El Forum - 08-07-2010 [eluser]Jelmer[/eluser] I'm guessing you've put the MY_Model.php file in application/libraries, which (as of CI2) isn't where it should go anymore. CI2 split the libraries into core libraries and normal libraries, and CI_Model is considered a core library and as such should go in application/core. CodeIgniter 2 can't extend CI_Model - El Forum - 08-07-2010 [eluser]Rui Lima[/eluser] Yes i wasn't putting it on Core. But when i put it there my application crashes How should it be called: MY_CI_Model extends CI_Model MY_Model extends CI_Model MY_CI_Model extends Model MY_Model extends Model I'm a bit confused CodeIgniter 2 can't extend CI_Model - El Forum - 08-07-2010 [eluser]Jelmer[/eluser] It should be "class MY_Model extends CI_Model", like almost every CI included class extention. But an application crash might be caused by anything, without the error message there's no way I could help you figure out what's wrong. If you're not seeing an error, make sure you have the error_reporting function in your main index.php set to E_ALL or something like that. If you're still not seeing an error at that point add this just below the error_reporting() function: Code: ini_set('display_errors', 'On'); CodeIgniter 2 can't extend CI_Model - El Forum - 08-07-2010 [eluser]John_Betong[/eluser] I have my model in the ./application/model/m_lib path and use autoload.php File: ./application/config/autoload.php Code: /* CodeIgniter 2 can't extend CI_Model - El Forum - 01-31-2011 [eluser]Unknown[/eluser] to solve. simply move MY_Model from: /application/libraries to: /application/core thankyou Jelmer. Your reply save the day ! CodeIgniter 2 can't extend CI_Model - El Forum - 08-25-2012 [eluser]Unknown[/eluser] thanks Jelmer. Help me a lot! |