I\'m using CodeIgniter 2.1.2 and here\'s my situation right now. I have a model named math.php in C:\\wamp\\www\\cr8v\\application\\models
. I am trying to load
Well, it should always be noted that function name should not be replicated with controller or model name such as below;
<?php
class Abc extends CI_Controller{
public function abc(){} // this confused CI in loading
}
this may be helpful for developers new to CI,
The name needs to be the same in all places:
Here:
class Math_model extends CI_Model {
// your model
}
Here:
$this->load->model("math_model");
When using it:
$this->math_model->add();
And: in your file system. So rename math.php
to math_model.php
and it will work.
The question has been answered really and the problem was this:
<?php
class Math_model extends CI_Model(){
//so on
}
?>
..it's the open and close parethesis after declaring the class.. it should be:
<?php
class Math_model extends CI_Model{
//so on
}
?>
thank you so much for those who responded
The name of the file should be math_model.php and you should call it like this:
echo $this->math_model->add();
File name and model name should be same try this instead
class Math_model extends CI_Model {
// your code
}
and the file name should be Math_model.php