Home Forums CodeIgniter send to model on update_city function get error city is already exist

Viewing 0 reply threads
  • Author
    Posts
    • #157
      abhijeet
      Participant

      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);
          }
Viewing 0 reply threads
  • You must be logged in to reply to this topic.
Scroll to Top