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 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持