[eluser]scherman[/eluser]
Hi, first of all, i don't speak english very well, so, i hope that you can understand me.
I am developing a project in Codeigniter, and i love the OOP, so i am trying to merge the OOP with Codeigniter. And i want to use the Active Record's methods.
So, i have this code:
Doctor_model.php
Code:
class Doctor_model extends CI_Model
{
public $id;
public $firstname;
public $lastname;
public function __construct()
{
$this->load->database();
}
public function save()
{
$datos = array(
'firstname' => $this->firstname,
'lastname' => $this->lastname
);
return $this->db->insert('doctors', $datos);
}
}
And in my controller i have this code:
Code:
class Doctors extends CI_Controller
{
function index()
{
$doctor = $this->load->model('doctor_model');
$doctor->firstname = $this->input->post('firstname');
$doctor->lastname = $this->input->post('lastname');
echo 'saving ' . $doctor->firstname;
if($doctor->save())
{
echo 'saved';
}
else
{
echo 'fail';
}
}
}
but when i run my controller's index method, it returns me this error:
Quote:Fatal error: Call to undefined method stdClass:ave() in [here the file and line]
Do somebody know what is my error? Do somebody know a better way for work in codeigniter with the OOP and use in the classes the Active Record's methods?
Thank you so much, and i hope that you can help me.
I accept criticism and advice from you!
Clarification: I've traduced the fields and the names of my code, because it was in spanish, so, maybe it has an error of the field's name.