How to Update Two table Data one after other In codeigniter?

ankit suthar

I create a model to update plan data but now with that i want to update the vendor_plan_task_mapping data because i use the plan data with vendor so when i update the plan after creating a vendor with some plan the updated plan data can't come to vendor task status mapping data hear i create a model for updating plan i have to update task_status_mapp table to be update...

how to update plan with vendor_plan_task_status_mapp table.

the model for plan update is

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') as $key => $value)

     {
        $data2 = array(

        'plan_id' => $planId,
        'task_id'   => $value

        );
     // echo "Index {$key}'s value is {$value}.";
           $this->db->insert('plan_task_mapping', $data2);
     }

//-------- HEAR I NEED A CODE TO UPDATE The V_T_S_M table-----------

}

after 1st table update i want to update the data in vendr_task_status_mapping table?????

bhargav Patel

IN THIS ANSWER YOU GET AN ERROR IF YOU CHANGE THE PLAN BUT USING THIS CODE YOU HAVE TO SIMPLY EDIT AND UPDATE IT ANGIN AND THIS MODEL IS CREATE A NEW ID FOR YOUR TASK AND INSERT IT 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() as $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;
         }

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to Update Two table Data one after other In codeigniter?

From Dev

Update one table based on data from two other tables

From Dev

Update one table based on data from two other tables

From Dev

Postgresql - How update another table after update one with specific data

From Dev

How to write triggers for an update on two table one after another

From Dev

How can I automatically update all other rows in the table after insert one new one in sql?

From Dev

Update table with no data codeigniter

From Dev

how to joint two table in codeigniter with jquery data table

From Dev

Codeigniter SQL query : i want to retrieve data from one table using the data from other table

From Dev

How to make two table condition to update one table

From Dev

running a query selecting data from one table and one of two possible other tables depending on data in the first table

From Dev

How to update two cells simultaneously, through one or the other?

From Dev

How to update two cells simultaneously, through one or the other?

From Dev

after making UNION ALL on two tables how could delete / update a specific row that has similer ID in other table?

From Dev

How to update a column with concatenate of two other column in a same table

From Dev

How to separate column data to copy from one table to other table?

From Dev

how fetch data from two table in codeigniter by using inner join

From Dev

CodeIgniter: How to Insert data with one name and multiple selectbox into the second table?

From Dev

Protractor and Angular: How to test two pages in an app, one after the other?

From Dev

How to Replace and Update Data From One Table to Another Table in MySQL

From Dev

How to Replace and Update Data From One Table to Another Table in MySQL

From Dev

how to update two records from different table in one query?

From Dev

How to update a field using trigger with data from other table?

From Dev

How to insert data from one table to other table by other mapping table through procedure

From Dev

Insert multiple data from other table in codeigniter

From Dev

Show data that is not in other table with join codeigniter

From Dev

how to update form data in codeigniter

From Dev

How to get one result with multiple data in other table

From Dev

SELECT and UPDATE statements one after other

Related Related

  1. 1

    How to Update Two table Data one after other In codeigniter?

  2. 2

    Update one table based on data from two other tables

  3. 3

    Update one table based on data from two other tables

  4. 4

    Postgresql - How update another table after update one with specific data

  5. 5

    How to write triggers for an update on two table one after another

  6. 6

    How can I automatically update all other rows in the table after insert one new one in sql?

  7. 7

    Update table with no data codeigniter

  8. 8

    how to joint two table in codeigniter with jquery data table

  9. 9

    Codeigniter SQL query : i want to retrieve data from one table using the data from other table

  10. 10

    How to make two table condition to update one table

  11. 11

    running a query selecting data from one table and one of two possible other tables depending on data in the first table

  12. 12

    How to update two cells simultaneously, through one or the other?

  13. 13

    How to update two cells simultaneously, through one or the other?

  14. 14

    after making UNION ALL on two tables how could delete / update a specific row that has similer ID in other table?

  15. 15

    How to update a column with concatenate of two other column in a same table

  16. 16

    How to separate column data to copy from one table to other table?

  17. 17

    how fetch data from two table in codeigniter by using inner join

  18. 18

    CodeIgniter: How to Insert data with one name and multiple selectbox into the second table?

  19. 19

    Protractor and Angular: How to test two pages in an app, one after the other?

  20. 20

    How to Replace and Update Data From One Table to Another Table in MySQL

  21. 21

    How to Replace and Update Data From One Table to Another Table in MySQL

  22. 22

    how to update two records from different table in one query?

  23. 23

    How to update a field using trigger with data from other table?

  24. 24

    How to insert data from one table to other table by other mapping table through procedure

  25. 25

    Insert multiple data from other table in codeigniter

  26. 26

    Show data that is not in other table with join codeigniter

  27. 27

    how to update form data in codeigniter

  28. 28

    How to get one result with multiple data in other table

  29. 29

    SELECT and UPDATE statements one after other

HotTag

Archive