![]() |
$this->load->model('Blog') - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: $this->load->model('Blog') (/showthread.php?tid=27242) Pages:
1
2
|
$this->load->model('Blog') - El Forum - 02-04-2010 [eluser]ignitian[/eluser] MODEL FILE : \application\models\blog.php Code: class Blog extends Model CONTROLLER FILE : \application\controllers\welcome.php Code: class Welcome extends Controller ERROR Code: A PHP Error was encountered A simple call that is not working. Database is autoload. Any tips ? $this->load->model('Blog') - El Forum - 02-04-2010 [eluser]Michael Wales[/eluser] CodeIgniter translates the class names to lowercase - it's actually the line below the one you identified that is erroring: Code: $data['query'] = $this->blog->get_last_ten_entries(); $this->load->model('Blog') - El Forum - 02-04-2010 [eluser]ignitian[/eluser] I still have the same error with the lowercase. Code: Message: Undefined property: Welcome::$blog $this->load->model('Blog') - El Forum - 02-04-2010 [eluser]danmontgomery[/eluser] What OS? [edit] nm, files named correctly, case sensitivity isn't an issue I would throw some code in the model file and in the constructor to determine if the file is being included/class is being instantiated, and go from there $this->load->model('Blog') - El Forum - 02-04-2010 [eluser]Michael Wales[/eluser] Is Blog listed within this dumped out variable? See code: Code: function get_last_news() $this->load->model('Blog') - El Forum - 02-04-2010 [eluser]ignitian[/eluser] Thanks for the help I got this... Array ( [0] => Blog ) 2nd Edit: Echo code into constructor worked also my OS is Windows XP, i use WAMP. C:\wamp\www\site1\index.php C:\wamp\www\site1\application C:\wamp\www\system $this->load->model('Blog') - El Forum - 02-04-2010 [eluser]Michael Wales[/eluser] What in the world... let's make sure we're on the same page - this function now looks like this: Code: function get_last_news() And the filename is models/blog.php. Correct? $this->load->model('Blog') - El Forum - 02-04-2010 [eluser]ignitian[/eluser] Exactly. include_path ?? $this->load->model('Blog') - El Forum - 02-04-2010 [eluser]Michael Wales[/eluser] No, that shouldn't be the issue (unless your other projects have a blog model as well). CodeIgniter would throw an error saying it can't find the model you are referring to if you request one it can not find. Just to make sure, let's open the index.php for this application and make sure the $application_folder setting is correct. Then, place the following bit of code in a controller somewhere so you can check the output: Code: echo APPPATH . 'models/' . $path . 'blog' . EXT; If you follow that path on your filesystem it should lead you straight to the model which includes the get_last_ten_entries() method. $this->load->model('Blog') - El Forum - 02-04-2010 [eluser]ignitian[/eluser] Code: echo APPPATH . 'models/' . $path . 'blog' . EXT; My model is not in a subfolder. It is correct. Code: application/models/blog.php I dont understand why this is not working. It's so simple what the... Code: http://localhost/site1/index.php/welcome/get_news |