【发布时间】:2016-08-09 06:50:22
【问题描述】:
我在控制器“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']);
但没有任何效果,非常感谢任何解决此问题的帮助。在此先感谢
【问题讨论】:
标签: php html mysql codeigniter