douqiao2471 2015-07-16 13:16
浏览 39
已采纳

在获取数据库表之后,我必须在codeigniter中编辑它

I have this three database table

vedd_plan_task

-task_id, -task_name,

tbl_plan

-plan_id, -plan_title, -plan_price, -plan_desc,

plan_task_mapping

-task_mapp_id, -plan_id, -task_id,

The Flow of process is like -- i am creating a edit/update/delete system of this data. i create a form to insert plan data,i fetch the task name dynamically on that page and the insert the data in to database with mapping technique. means while inserting i mapped the Plan_id and Task_id in mapping table.

I successfully inserted it. and display in my view table. now i have to edit this detail. but first i have to show this detail in my view (like plan detail in input box as plan the selected task in check box)

Now i have to fetch this data for edit them ... i can't fetch the proper way as.. Means can't get proper task_name as plan_id. Help me please...

"plan_title | plan_price | plan_desc | task_name "

This is the plan Model

public function getPlanById($planId)
{
    $this->db->where('plan_id', $planId);
    $query = $this->db->get('tbl_plan');
    return $query->result();    
}

public function getPlanAndTaskMappingByPlanId($planId)
{      
    $this->db->where('plan_id', $planId);
    $query = $this->db->get('plan_task_mapping');
    return $query->result();   
}

function getAllVeddingTask()
{   
    $query = $this->db->get('vedd_plan_task');
    return $query->result();
}

This is the controller

public function editPlanData($planId)
{
    $data['veddingPlanData'] = $this->PlanModel->getPlanById($planId);
    $data['veddingPlanTaskMappingData'] = $this->PlanModel->getPlanAndTaskMappingByPlanId($planId);
    $data['allVedingTasks'] = $this->VeddingTaskModel->getAllVeddingTask();
    $this->load->view('plan_update', $data);
}

I dump data successfully... in my view now i have to show only that task which is selected for plan.. means the i have to show task_name as plan_id. threw mapping tale

<?php  var_dump($veddingPlanData);  ?>
<?php  var_dump($veddingPlanTaskMappingData);  ?>
<?php  var_dump($allVedingTasks);  ?>

this is my view

now help me to fetch that plan with the specific task_name as check box and plan data in input box.. hear in view i comment the dump part .. i dump it successfully. so i just want to edit that data which is called on product id.. as product id the data come from mapping and then the task_name came form task table.

  • 写回答

1条回答 默认 最新

  • duanlv1366 2017-08-17 16:47
    关注

    I have asked this question many years ago when I have started the Codeigniter. So I am posting the answer to my own question.

    In this question, I needed to get data using join for edit vedding_task according to vedding_task.

    So here is the JOIN query.

    $prop_master_table = $this->db
        ->select('*')
        ->from('plan_task_mapping as ptm')
        ->join('vedd_plan_task as vpt', 'ptm.task_id = vpt.task_id', 'left outer')
        ->join('tbl_plan as tp', 'ptm.plan_id = tp.plan_id', 'left outer')                
        ->where('vpt.task_id', $task_id)
        ->where('tp.plan_id', $plan_id)
        ->get();
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应