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();
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 icefall在librispeech基础上加入个人数据集
  • ¥30 keepalive高可用故障运维配置询问
  • ¥15 求帮助!国家电网内网u盘突然识别不出来了。
  • ¥15 matlab语音变速变调同时实现
  • ¥15 如何用Thoony写ESP32温湿度检测无源蜂鸣器报警代码?
  • ¥20 部件内部的CT图像数据集
  • ¥15 Visual studio调用动态库
  • ¥15 双目摄像头标定后的校准文件
  • ¥15 powerbi矩阵增加度量值后出现对应关系错乱
  • ¥30 频率分析法分析绘制奈奎斯特图、波特图