2017-06-26 10 views
-1

2つの異なるテーブルと同じ列名、両方のテーブルに電子メールIDチェックを挿入中に、テーブルに挿入されません。2つの異なるテーブルと同じ列名、両方のテーブルに電子メールIDのチェックを挿入中に再度挿入しない場合

モデルコード

function form_insert($data, $data1) { 
    if ($data1['categoryvalues'] == 'Seller') { 
     $this->db->insert('supplier_registration', $data); 
     return ($this->db->affected_rows() != 1) ? false : true; 
    } else { 

     $this->db->insert('customer_registration', $data); 
     return ($this->db->affected_rows() != 1) ? false : true; 
    } 
} 

コントローラコード

function register() { 
    $this->form_validation->set_rules('email', 'Email', 'callback_rolekey_exists'); 
    $this->form_validation->set_rules('fname', 'First Name', 'required|min_length[3]|max_length[30]'); 
    $this->form_validation->set_rules('lname', 'Last Name', 'required|min_length[3]|max_length[30]'); 
    $this->form_validation->set_rules('email', 'Email ID', 'required|valid_email|is_unique[supplier_registration.email]'); 

    $this->form_validation->set_rules('mobileno', 'Mobile No', 'required|regex_match[/^[0-9]{10}$/]'); 
    $this->form_validation->set_rules('password', 'Password', 'trim|required|max_length[15]|min_length[8]|matches[ConfirmPassword]'); 
    $this->form_validation->set_rules('ConfirmPassword', 'Confirm Password', 'trim|required'); 

    if ($this->form_validation->run() == FALSE) { 

     $data['ListMenuLevel1'] = $this->Categories_model->listsector1(); 
     $data['groups1'] = $this->productdisplay_model->fetchingdata(); 
     $data['flag2'] = "yes"; 
     //$data['message']="invalid username or password"; 
     $this->load->view('home', $data); 
     //$data['flag'] = 'yes'; 
     //$this->load->view('login', $data); 
    } else { 

     $data = array(
      'first_name' => $this->input->post('fname'), 
      'last_name' => $this->input->post('lname'), 
      'email' => $this->input->post('email'), 
      'mobile_no' => $this->input->post('mobileno'), 
      'password' => $this->input->post('password') 
     ); 
     $data1['categoryvalues'] = $this->input->post('optradio'); 

     if ($this->Register_model->form_insert($data, $data1)) { 
      $data['ListMenuLevel1'] = $this->Categories_model->listsector1(); 
      $data['groups1'] = $this->productdisplay_model->fetchingdata(); 
      $data['message'] = 'Data Inserted Successfully'; 
      $this->load->view('home', $data); 
     } 
    } 
} 
+3

わかりやすい適切な質問を書くのに、実際には数分を費やす必要があります。今すぐあなたは混乱の文章を書いてあなたのコードをダンプしました –

+0

あなたは両方のテーブルの電子メールフィールドに一意のインデックスを追加することができます。 –

答えて

1

私の知る限りでは、あなたが複数回is_uniqueチェックを使用することができない理由はありません。

$this->form_validation->set_rules('email', 'Email ID', 'required|valid_email|is_unique[supplier_registration.email]|is_unique[customer_registration.email]'); 
関連する問題