1
我有在控制器「thisTopic」的函數模型返回的陣列讀取的特定字段,其具有以下:如何從由控制器本身
$viewdata = array();
$viewdata['reply'] = $this->disc->get_all_replies($topic_id);
$viewdata['firstReply']= $this->disc->get_firstReply();
在模型:
public function get_all_replies($topic_id){
return $results = $this->db->select('*')
->from('disc_replies')
->join('users', 'users.id = disc_replies.users_id')
->where('topic_id',$topic_id)
->get()->result();
}
public function get_firstReply($reply_id){
return $results = $this->db->select('*')
->from('disc_firstReply')
->join('users', 'users.id = disc_firstReply.users_id')
->where('reply_id',$reply_id)
->get()->result();
}
的disc_replies
表有以下幾列:
1. reply_id
2. topic_id
3. users_id
4. replied_on
從$viewdata['reply']
我想讀取第一行的reply_id字段,並將其作爲參數發送給get_firstReply()
函數。
這是我試過到目前爲止:
$viewdata['firstReply']= $this->disc->get_firstReply($viewdata['reply'][0]['reply_id']);
$viewdata['firstReply']= $this->disc->get_firstReply($viewdata['reply']['reply_id']);
但沒有任何工程,任何幫助解決這個問題真的讚賞。在此先感謝