2 回答

TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超7個(gè)贊
問題是 -get_where()已經(jīng)返回一個(gè)數(shù)據(jù)庫結(jié)果實(shí)例 - 為了解決您的問題,您必須執(zhí)行類似的操作
return $this->db
->select('*')
->from('target')
->where('staff_id', get_staff_user_id())
->order_by('id', 'desc')
->limit(3,1)
->get();

TA貢獻(xiàn)1865條經(jīng)驗(yàn) 獲得超7個(gè)贊
在模型中:
刪除多余的逗號
$id=get_staff_user_id();
$this->db->get_where('target', array('staff_id'=>$id));
$this->db->order_by('id','desc');
$this->db->limit(3, 1);
$query=$this->db->get();
return $query;
在控制器中:
將目標(biāo)更改為目標(biāo),就像在 foreach 中一樣,它從相同的數(shù)組名稱中獲取;
$data['targets'] = $this->target_model->getAllTarget()->result();
- 2 回答
- 0 關(guān)注
- 180 瀏覽
添加回答
舉報(bào)