[eluser]johnmiller[/eluser]
Hi...
i have a doubt in returning an id from model to controller
The below is a function in my controller
Code:
function add_student()
{
$fname = $this->input->post('fname');
$lname = $this->input->post('fname');
$this->load->model('student_model');
$data['query_add_student'] = $this->student_model->add_student($fname, $lname);
}
These values pass to the model and insert to the table
Code:
function add_student($fname, $lname)
{
$query_add_student = $this->db->query('INSERT INTO student (fname, lname) VALUES ('.$fname.', '.$lname.')');
}
Now i need to return last inserted row id
i tried
but i am confused how to write that and return..
how to get the last inserted row id here
i need to return that id to the controller...
and from the controller, i need to view a page using this id
how to write the code in model and controller?
can anyone help me???