Error while replicating Blogmodel example in tutorial

#1
[eluser]Unknown[/eluser]
Newbie here (first day with CodeIgniter - I'm diggin it!)

Env:
CodeIgniter 1.7.0 (website says works with PHP5)
PHP5 - PHP 5.2.6-2ubuntu4 with Suhosin-Patch 0.9.6.2 (cli)
Apache/2.2.9 (Ubuntu)
Ubuntu 8.10 64bit


Problem is:

I am trying to load a model and am getting an error emanating from Loader.php.

Here is the error (note that it includes the model contents so the file *is* being found):

==========
Error
==========
class Blogmodel extends Model { function _construct() { // Call the Model constructor parent::Model(); } }
Fatal error: Class 'Blogmodel' not found in /var/www/system/libraries/Loader.php on line 184
==========

I *think* that the class/function/file naming is correct:

Model location and name:
.../models/blogmodel.php

From my controller:
$this->load->model('blogmodel');


Very simple Model contents:
=====
class Blogmodel extends Model {

// (doesn't work with Blogmodel() constructor either)
function _construct()
{
// Call the Model constructor
parent::Model();
}

}
=====

Any ideas? Based on the excellent tutorials I have found, this should all be working.

Bob

#2
[eluser]Murodese[/eluser]
Couple of things:

A constructor in php5 is __construct() (double underscore)

I don't remember if this will specifically matter but most models are table_model.php, so it'd be Blog_model.php rather than Blogmodel.php - this also means the class itself will be called Blog_model and when you go to load it, you'd be loading blog_model.

#3
[eluser]Unknown[/eluser]
I got it. Doy.

I was missing the opening and closing PHP tags on the model page. Like I said - newbie.

Thanks for the help.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.