我找不到这个问题的解决方案:严重性:注意 --> 试图获取非对象的属性
请帮助我找出我的错误。
我的模型方法:
function get_AllDays_by_templateRoutine_id($rid)
{
$this->load->database();
$this->db->select('day_id');
$res = $this->db->order_by('day_id', 'DESC')->get_where('template_user_days', array('routine_id'=> $rid));
$ret = array();
foreach ($res->result_array() as $row) {
$ret[] = $row['day_id'];
}
return $ret;
}
和我的控制器
public function install_template()
{
$rid = $this->input->post('rid');
$userid=$this->session->userdata('userid');
$urid=$this->routinemodel->getMaxUserRoutineId($userid);//method returning one value
$userdays_template=$this->templateroutinemodel->get_AllDays_by_templateRoutine_id($rid);
if(is_array($userdays_template))
{
foreach ($userdays_template as $row2)
{
$day_value=$row2['day_id'];//Error:--> Trying to get property of non-object**
}
}
}
}