@pradeep, я добавил проверку на стороне клиента, используя Jquery и проверку на стороне сервера, которая находится в приведенном выше коде. Я просто хочу знать, что я на правильном пути, чтобы вставить данные в несколько таблиц?

ользую Codeginator, у меня есть три таблицы (это будет увеличиваться в будущем в соответствии с требованием) и названия таблиц"tbl_customer", "tbl_customer_billing","tbl_customer_shipping", Каждая таблица связана с первичным ключом и внешним ключом.

Теперь я вставляю данные в каждую таблицу, поэтому я попробовал код ниже.

Мой вопрос:

1) я должен использовать$this->security->xss_clean() для каждого массива? или любая другая идея использовать только одинxss_clean?

2) Каков наилучший и быстрый способ вставить данные в несколько таблиц?

Я попробовал ниже код. Это нормально, или я должен использовать что-то другое? Я попробовал код ниже, но есть много изменений, чтобы потерять данные. Есть ли другая идея?

контроллер:

public function add_newcustomer(){
        $this->form_validation->set_error_delimiters('<div class="error">', '</div>');
        $this->form_validation->set_rules('c_firstname', 'Firstname', 'trim|required|min_length[3]|max_length[25]');
        $this->form_validation->set_rules('c_lastname', 'Lastname', 'trim|required|min_length[3]|max_length[25]');

        $this->form_validation->set_rules('c_email', 'Email', 'required');
        $this->form_validation->set_rules('c_mobileno', 'Mobile no', 'trim|required|regex_match[/^[0-9]{10}$/]');
        $this->form_validation->set_rules('c_billing_address', 'Billing Address', 'required|min_length[10]|max_length[100]');
        $this->form_validation->set_rules('c_b_country', 'Country', 'required');
        $this->form_validation->set_rules('c_b_state', 'State', 'required');
        $this->form_validation->set_rules('c_b_city', 'City', 'required');
        $this->form_validation->set_rules('c_b_zipcode', 'Zip code', 'required');
        $this->form_validation->set_rules('c_shopping_address', 'Shopping Address', 'required|min_length[10]|max_length[100]');
        $this->form_validation->set_rules('c_s_country', 'Country', 'required');
        $this->form_validation->set_rules('c_s_state', 'State', 'required');
        $this->form_validation->set_rules('c_s_city', 'City', 'required');
        $this->form_validation->set_rules('c_s_zipcode', 'Zip code', 'required');
        if ($this->form_validation->run() == FALSE)
                {
                $data['get_country']=$this->Customer_model->get_country();// all country name
                $this->load->view('create_order',$data);
                 }
                 else
                {
        $cust_personal = array(
                'c_firstname'=>$this->input->post('c_firstname'),
                'c_middlename'=>$this->input->post('c_middlename'),
                'c_lastname'=>$this->input->post('c_lastname'),
                'c_email_id'=>$this->input->post('c_email'),
                'c_mobileno'=>$this->input->post('c_mobileno'),
                'c_alternetno'=>$this->input->post('c_alternetno'),
                'c_created_by_emp'=>$this->session->userdata['login_session']['id'],
                'c_date_of_added'=>$this->current_date
                 );
            $this->db->insert('tbl_customer',$cust_personal);
            $last_cust_id= $this->db->insert_id();


        $cust_billing = array(
                'c_b_address'=>$this-&,gt;input->post('c_billing_address'),
                'c_b_country'=>$this->input->post('c_b_country'),
                'c_b_state'=>$this->input->post('c_b_state'),
                'c_b_city'=>$this->input->post('c_b_city'),
                'c_b_zipcode'=>$this->input->post('c_b_zipcode'),
                'cust_id'=>$last_cust_id,
                'c_date_of_added'=>$this->current_date
            );
            $this->db->insert('tbl_customer_billing',$cust_billing);
            $last_billing_id= $this->db->insert_id();

         $cust_shipping = array(

                'c_s_address '=>$this->input->post('c_shopping_address'),
                'c_s_country'=>$this->input->post('c_s_country'),
                'c_s_state'=>$this->input->post('c_s_state'),
                'c_s_city'=>$this->input->post('c_s_city'),
                'c_s_zipcode'=>$this->input->post('c_s_zipcode'),
                'c_s_receiver_no'=>$this->input->post('c_receiver_no'),
                'cust_id'=>$last_cust_id,
                'c_billing_id'=>$last_billing_id,
                'c_date_of_added'=>$this->current_date
            );

            $this->db->insert('tbl_customer_shipping',$cust_shipping);

            redirect("Customer_control/index");

                }
}

Ответы на вопрос(0)

Ваш ответ на вопрос