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 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵