php - How to Update Two table Data one after other In codeigniter? -
how update plan vendor_plan_task_status_mapp table.
the model plan update
public function updateplandata(){ $planid = $this->input->post('plan_id'); $data = array( 'plan_title' => $this->input->post('plan_title'), 'plan_price' => $this->input->post('plan_price'), 'plan_desc' => $this->input->post('plan_desc') ); $this->db->where('plan_id', $planid); $this->db->update('tbl_plan', $data); $this->db->where('plan_id',$planid); $this->db->delete('plan_task_mapping'); foreach ($this->input->post('task_id') $key => $value) { $data2 = array( 'plan_id' => $planid, 'task_id' => $value ); // echo "index {$key}'s value {$value}."; $this->db->insert('plan_task_mapping', $data2); } //-------- hear need code update v_t_s_m table----------- }
after 1st table update want update data in vendr_task_status_mapping table?????
in answer error if change plan using code have edit , update angin , model create new id task , insert again.
public function vendorupdatemodel($data) { $vendor_id = $this->input->post('vendor_id'); $data = array( 'category_id' => $this->input->post('category_id'), 'plan_id' => $this->input->post('plan_id'), 'city_id' => $this->input->post('city_id'), 'business_name' => $this->input->post('business_name'), 'owner_name' => $this->input->post('owner_name'), 'contact_no1' => $this->input->post('contact_no1'), 'contact_no2' => $this->input->post('contact_no2'), 'vendor_email' => $this->input->post('vendor_email'), 'subscription_date' => $this->input->post('subscription_date'), 'vendor_description' => $this->input->post('vendor_description'), 'vendor_address' => $this->input->post('vendor_address') ); $this->db->where('vendor_id', $vendor_id); $this->db->update('vendor',$data); $this->db->where('vendor_id',$vendor_id); $this->db->delete('vendor_task_status_mapping'); $this->db->select('task_mapp_id'); $this->db->where('plan_id',$this->input->post('plan_id')); $query = $this->db->get('plan_task_mapping'); foreach($query->result() $row) { $data2 = array( 'task_mapp_id' => $row->task_mapp_id, 'vendor_id' => $vendor_id, 'task_status' => '0' ); $this->db->insert('vendor_task_status_mapping', $data2); } return; }
Comments
Post a Comment