Autoloading Models PHP 5 Style |
[eluser]gcarrion[/eluser]
Hi, I found this article posted over at Nettuts with pretty neat hacks: http://net.tutsplus.com/tutorials/php/6-...e-masters/ I would like to use "hack" #1 (specially for the auto-complete feature in the IDE and the simplicity to call models), but is not working for me. I keep getting errors when running the page. I added the required code to the end of application/config/config.php Code: function __autoload($class) { Then created a test controller: application/controllers/test.php Code: <?php I then created a test model: application/models/test_model.php Code: <?php When I run the URL: mysite.com/test/ I get this message: Quote:Fatal error: Class 'Model' not found in /path/to/web/application/models/test_model.php on line 2 Tried removing the "extends Model" from the test_model.php to be like this: Code: class Test_model { Then ran it again and got this error: Quote:A PHP Error was encountered However, If I call the model the original way in the controller, it works fine. Code: $this->load->model('test_model'); Any ideas of what I'm doing wrong? Thanks! |
Messages In This Thread |
Autoloading Models PHP 5 Style - by El Forum - 12-29-2009, 05:36 PM
Autoloading Models PHP 5 Style - by El Forum - 12-29-2009, 07:49 PM
Autoloading Models PHP 5 Style - by El Forum - 12-29-2009, 08:52 PM
Autoloading Models PHP 5 Style - by El Forum - 12-29-2009, 08:57 PM
Autoloading Models PHP 5 Style - by El Forum - 12-29-2009, 09:17 PM
Autoloading Models PHP 5 Style - by El Forum - 12-30-2009, 12:42 AM
Autoloading Models PHP 5 Style - by El Forum - 12-30-2009, 03:05 AM
Autoloading Models PHP 5 Style - by El Forum - 12-30-2009, 04:39 PM
Autoloading Models PHP 5 Style - by El Forum - 12-31-2009, 06:27 AM
Autoloading Models PHP 5 Style - by El Forum - 01-01-2010, 09:10 AM
Autoloading Models PHP 5 Style - by El Forum - 01-01-2010, 09:30 AM
|