is unique in codeigniter form validation

Solutions on MaxInterview for is unique in codeigniter form validation by the best coders in the world

showing results for - "is unique in codeigniter form validation"
Lisandro
09 Mar 2018
1$this->form_validation->set_rules('order_no', 'Order no', 'required|callback_check_order_no');
2
Lennart
22 Jun 2016
1function check_unique_order_no($id = '', $order_no) {
2        $this->db->where('order_no', $order_no);
3        $this->db->where('status', "A");
4
5        if($id) {
6            $this->db->where_not_in('id', $id);
7        }
8        return $this->db->get('delivery_order')->num_rows();
9    }
10
Ida
13 Nov 2017
1function check_order_no($order_no) {        
2        if($this->input->post('id'))
3            $id = $this->input->post('id');
4        else
5            $id = '';
6        $result = $this->Data_model->check_unique_order_no($id, $order_no);
7        if($result == 0)
8            $response = true;
9        else {
10            $this->form_validation->set_message('check_order_no', 'Order no already exist');
11            $response = false;
12        }
13        return $response;
14    }
15