I have the general table
I also have the table line
And finally I have the company_line table
What I want to do is that when I insert in the general table the general_id of the new record is passed to the company_line table and also put in the same table and the same record the line_id that I already get from the form
My Controller with the data I want to insert as an example
public function add_empresa_linea(){//aqui debo de insertar en dos tablas
$data = array(
'nombre' => $this->input->post('txt_nombre'),
'id_servicio' => 1,
);
$id_linea = $this->input->post('combo_linea');
$insert = $this->reg_calls_model->add_empresa_linea($data);
if ($insert) {
echo json_encode(array("status" => TRUE));
}
}
My Model
function add_empresa_linea($data){
try {
$result = $this->db->insert('general',$data);
return $result;
} catch(Exception $e) {
show_error($e->getMessage() . ' --- ' . $e->getTraceAsString());
}
}