I'm very new to CodeIgniter and am currently in the process of rewriting a site of mine so that it's compatible with CI. I have controller file located at /application/controllers/user.php
if(!defined('BASEPATH'))
{
exit('No direct script access allowed');
} else
{
class user extends CI_Controller
{
public function index()
{
$this->load->library('customautoloader');
$this->load->model('user', '', true);
$data = array('title' => 'Title goes here',
'body' => 'The string to be embedded here!');
$this->load->library('template');
$this->template->load('default', null, $data);
}
}
}
In application/models/user.php, I have the following:
namespace models; // set namespace
if(! defined('BASEPATH'))
{
exit('No direct script access allowed');
} else
{
class User
{
...
}
}
When I put the following url into my browser:
http://localhost:8888/CodeIgniter/user/
I'm greeted with an error message that reads:
"Fatal error: Call to a member function load() on a non-object"
I know this may be a simpleton question, but I'm very new to CI and the rules that it uses.
Thanks
I believe you should extends CI_Model in application/models/user.php
class User extends CI_Model {
// your codes here
}
Here is the document for using Codeigniter model http://ellislab.com/codeigniter/user-guide/general/models.html