Codeigniter:尝试从数组传递单个值时的“未定义索引”

时间:2016-04-06 08:28:51

标签: php mysql codeigniter

我正在使用模型设置$data['Milestone'];

$data['Milestone'] = $this->Work_model->GetMilestone($this->UserID, $this->MilestoneID);

这会从SQL返回几行,我需要将一个特定的行传递给视图,这是我尝试过的;

$this->pageData = array('pageTitle' => $data['Milestone']['MilestoneName']);
$this->load->view('includes/Header_view', $this->pageData);

在页面上我收到此错误:

  

严重性:通知消息:未定义的索引:MilestoneName文件名:   controllers / Views_controller.php行号:86

如何仅将MilestoneName传递给视图?

编辑:按要求的模型:

public function GetMilestone($UserID, $MilestoneID){
  $query = $this->db->query("SELECT * FROM FYP_Milestones
                            INNER JOIN FYP_Modules ON FYP_Milestones.ModuleID = FYP_Modules.ID
                            INNER JOIN FYP_Accounts ON FYP_Modules.PathwayID = FYP_Accounts.PathwayID
                            LEFT JOIN FYP_Submissions ON FYP_Milestones.MilestoneID = FYP_Submissions.MatchMilestoneID AND FYP_Submissions.UserID = $UserID 
                            LEFT JOIN FYP_MilestoneNotes ON FYP_Milestones.MilestoneID = FYP_MilestoneNotes.NotesMilestoneID AND FYP_MilestoneNotes.UserID = $UserID AND FYP_MilestoneNotes.NotesMilestoneID = $MilestoneID
                            WHERE FYP_Milestones.MilestoneID = $MilestoneID
                            AND FYP_Accounts.UserID = $UserID                                
                            LIMIT 1");
  return $query->result();
}

SQL结果图片:enter image description here

0 个答案:

没有答案