我正在使用模型设置$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();
}