일련의 필드를 사용하고 다른 값을 다른 데이터베이스에 입력하는 함수를 작성하려고합니다. 지금은 단 두 개의 별도 데이터베이스 항목이지만 더 나중에 구현하려고합니다. 한 테이블에 새 Saint를 입력하고 사용자가 'ofRegion'필드를 채우면 다른 테이블에 저장하려고합니다. 모델이 'ofRegion'에 대한 정보를 입력하려고 할 때 내 문제가 발생합니다. 알 수없는 열이 있다는 MySQL 오류 (1054)가 표시됩니다. MySQL 오류로 인해 이전 항목의 모든 정보와 새 정보를 입력하려고한다는 것을 알 수 있습니다. 이전 정보는 어떻게 지울 수 있습니까? 이 작업을 수행 할 수 있습니까? 아니면 정보를 입력하려는 각 테이블에 대해 여러 모델이 필요합니까?CodeIgniter 컨트롤러 함수에서 둘 이상의 모델 호출을 시도 할 때 MySQL 오류 1054
모델 함수
public function input_saint($newSaintID)
{
//grab values from post stream
$this->saintID = $newSaintID;
$this->active = 1;
$this->nameFirst = $this->input->post('nameFirst');
$this->nameLast = $this->input->post('nameLast');
$this->gender = $this->input->post('gender');
$this->martyr = $this->input->post('martyr');
$this->nationality = $this->input->post('nationality');
$this->feastMonth = $this->input->post('feastMonth');
$this->feastDay = $this->input->post('feastDay');
$this->about = $this->input->post('about');
//insert information into the saint table
$this->db->insert('saint_table', $this);
}
public function set_of_region($newSaintID)
{
$this->saintID = $newSaintID;
$this->ofRegion = $this->input->post('ofRegion');
$this->db->insert('saint_of_region', $this);
}
컨트롤러 기능
public function saint_input()
{
//Check if user is logged in, if they are not, send them to the login screen
if($this->session->userdata('logged_in') == FALSE)
{
redirect('base/');
}
$this->load->library('form_validation');
//load Saint model and get the nation list
$this->load->model('saint_model');
//Load the nation list
$data['nationList'] = $this->saint_model->get_nations();
if($this->form_validation->run('saint_input')==FALSE)
{
$this->load->view('std/top');
$this->load->view('forms/saint_input', $data);
$this->load->view('std/bottom');
}
else
{
//generate saintID
$newSaintID = $this->saint_model->get_largest_saintID();
$newSaintID++;
$this->saint_model->input_saint($newSaintID);
//if specified, record the ofRegion
if($this->input->post('ofRegion') != NULL)
{
$this->saint_model->set_of_region($newSaintID);
}
//Send the user to this saint's single view page for review
redirect('base/display_one_saint/'.$newSaintID);
}
}
당신의 시간과 일을 주셔서 감사합니다!