[eluser]Sean Cannon[/eluser]
My problem is pretty simple. In my view I have a form to insert data. The data needs to go into two separate tables.
Here is my controller function:
Code:
function insert()
{
$peopleInfo = array(
'person_title' => $this->input->post('person_title'),
'person_firstname' => $this->input->post('person_firstname'),
'person_lastname' => $this->input->post('person_lastname'),
'person_suffix' => $this->input->post('person_suffix'),
'person_gender' => $this->input->post('person_gender'),
'person_agerange' => $this->input->post('person_agerange'),
'person_birthdate' => $this->input->post('person_birthdate'),
'person_maritalstatus' => $this->input->post('person_maritalstatus'),
'person_anniversary' => $this->input->post('person_anniversary'),
'person_address' => $this->input->post('person_address'),
'person_city' => $this->input->post('person_city'),
'person_state' => $this->input->post('person_state'),
'person_zipcode' => $this->input->post('person_zipcode'),
'person_mailaddress' => $this->input->post('person_mailaddress'),
'person_mailcity' => $this->input->post('person_mailcity'),
'person_mailstate' => $this->input->post('person_mailstate'),
'person_mailzipcode' => $this->input->post('person_mailzipcode'),
);
$memberInfo = array(
'person_id' => , //THIS IS WHERE I AM STUCK!!
'member_type' => $this->input->post('member_type'),
'member_startdate' => $this->input->post('member_startdate'),
'member_joinedhow' => $this->input->post('member_joinedhow'),
);
if ($this->people->addPeople($peopleInfo,$memberInfo))
{
redirect('people');
}
My model function simply looks like this:
Code:
function addPeople($peopleInfo,$memberInfo)
{
$this->db->insert('nx_people', $peopleInfo);
$this->db->insert('nx_membership', $memberInfo);
return TRUE;
}
What I can't figure out is if I can grab the person_id that has just been inserted so that I can use it in the nx_membership table. Is it possible to do this? Any tips are greatly appreciated!