我正試圖從視圖中的模型查詢訪問結果集。我有以下幾點:codeignite試圖獲取非對象的屬性未解決
控制器:
$courseId = $this->session->userdata('courseId');
//echo "Course: ".$courseId;
if(isset($courseId) && $courseId != '')
{
$result = $this->Course_model->loadBasicDetailsEdit($courseId);
$data['basicCourseDetails'] = $result;
$this->load->view('course/basicDetails', $data);
}
型號:
function loadBasicDetailsEdit($courseId)
{
$this->db->select('*');
$this->db->where('course_id', $courseId);
$this->db->from('course');
$query = $this->db->get();
if ($query->num_rows() > 0)
{
return $query->result();
} else {
return FALSE;
}
}
和我想的print_r(),並得到了這個觀點:
Array ([0] => stdClass Object ([course_id] => 8 [title] => Photography [summary] => [description] => [price] => [member_id] => 12 [category] => [audience] => [goals] => [date] => 2013-09-26 [production] => 0))
我試着使用$ basicCourseDetails-> title或$ basicCourseDetails ['title'] 來訪問它,但都不是w工作會有。任何暗示爲什麼會發生這種情況?
問候,
謝謝亞歷山德羅,但如果我不想循環。只要將它作爲對象屬性來訪問? – spacemonkey
請嘗試我的更新請@spacemonkey –
不,那仍然是試圖獲得非對象的屬性 – spacemonkey