Welcome Guest, Not a member yet? Register   Sign In
Insert auto increment using insert_id
#5

[eluser]Ralanyo[/eluser]
Great! That worked. I've been trying to figure this out for about 3 hours. Thank you. Here is the code that i used based off your recommendations. Basically the same with some semicolons because i was getting errors.

Code:
$company['companyname'] = $this->input->post('company');    
       $sales = array(
       'name' => $this->input->post('salesrep')
       );
      
          $this->db->insert('salesperson', $sales);
         $company['salespersonid'] = $this->db->insert_id();

          $this->db->insert('company', $company);

In regards to the MVC. Right now I have this code in my model and my controller has the following which passess it to the view. Is this not correct MVC?

Code:
public function insertMore()
    {
    $this->form_validation->set_rules('company', 'company', 'required');
  if ($this->form_validation->run() === FALSE)
{
  $this->load->view('companymore');
  
}
else
{
  $this->load->model('Company_model');
  
  $this->Company_model->insertMore();
  $this->load->view('companysuccess');
}



Messages In This Thread
Insert auto increment using insert_id - by El Forum - 08-11-2012, 07:43 PM
Insert auto increment using insert_id - by El Forum - 08-11-2012, 07:51 PM
Insert auto increment using insert_id - by El Forum - 08-11-2012, 07:59 PM
Insert auto increment using insert_id - by El Forum - 08-11-2012, 08:03 PM
Insert auto increment using insert_id - by El Forum - 08-11-2012, 08:16 PM
Insert auto increment using insert_id - by El Forum - 08-11-2012, 08:17 PM
Insert auto increment using insert_id - by El Forum - 08-11-2012, 08:30 PM
Insert auto increment using insert_id - by El Forum - 08-11-2012, 08:33 PM
Insert auto increment using insert_id - by El Forum - 08-11-2012, 08:40 PM



Theme © iAndrew 2016 - Forum software by © MyBB