I am do this then solve error have any other way
public function insert_city()
{
$city_id = $this->input->post('city_id');
$this->load->library('form_validation');
$this->form_validation->set_rules('city', 'City', 'required|is_unique[city_table.city]', array('is_unique' => 'City already exist.'));
if ($this->form_validation->run()) {
if ($this->input->post()) {
$state_id = $this->input->post('state_id');
$city = $this->input->post('city');
$city_meta_title = $this->input->post('city_meta_title');
$city_meta_description = $this->input->post('city_meta_description');
}
$data = array('state_id' => $state_id, 'city' => $city,'city_meta_title'=>$city_meta_title,'city_meta_description'=>$city_meta_description);
$this->load->model('Action_Model');
$this->Action_Model->insert_city($data);
}
else {
$this->load->view('admin/add-city');
}
if($city_id){
if ($this->input->post()) {
$state_id = $this->input->post('state_id');
$city = $this->input->post('city');
$city_meta_title = $this->input->post('city_meta_title');
$city_meta_description = $this->input->post('city_meta_description');
}
$data = array('state_id' => $state_id, 'city' => $city,'city_meta_title'=>$city_meta_title,'city_meta_description'=>$city_meta_description);
$this->load->model('Action_Model');
$this->Action_Model->update_city($data, $city_id);
}