codeigniter form validation is_unique example
Example 1: is_unique in codeigniter form validation
$this->form_validation->set_rules('order_no', 'Order no', 'required|callback_check_order_no');
Example 2: is_unique in codeigniter form validation
function check_unique_order_no($id = '', $order_no) {
$this->db->where('order_no', $order_no);
$this->db->where('status', "A");
if($id) {
$this->db->where_not_in('id', $id);
}
return $this->db->get('delivery_order')->num_rows();
}