试图获得非对象的属性

时间:2015-09-13 08:51:44

标签: php codeigniter model-view-controller

我正在尝试将用户的ID从一个视图传递到另一个视图,并显示相应id的配置文件详细信息。但不显示配置文件详细信息,我收到错误消息“尝试获取非对象的属性。

这是第一个视图

<td class="user-name"><a href="<?php echo site_url() . 'admin/users/members_details/' . $allusers->p_u_id; ?>"> <?php echo $allusers->comp_person_name ?></a>   <span>Subscriber</span> </td>

控制器:members_details方法

public function members_details () {
     $data['udetails']= $this->user_model->user_details(array('u_id' => $this->uri->segment(4) , 'u_delete' => 1 ));
 $this->layout->view("admin/members_details", $data);
}

user_details模型

 function user_details($where = '', $order = '', $select = '') {
        if (!$select)
            $select = array('users.u_id', 'users.u_email', 'u_status', 'u_group', 'user_profile.*', 'cities.*', 'country.*');

        $joins = array(array('table' => 'user_profile', 'condition' => 'user_profile.p_u_id=users.u_id', 'jointype' => 'INNER'),
            array('table' => 'cities', 'condition' => 'user_profile.comp_city=cities.id', 'jointype' => 'INNER'),
            array('table' => 'country', 'condition' => 'user_profile.comp_country=country.id', 'jointype' => 'INNER'));
        if ($order)
            $this->db->order_by($order);
        else
            $this->db->order_by('u_id  DESC');

        return $this->get_joins('users', $where, $joins, $select);
    }

members_details视图

<a href="#" class="user-name">
<?php echo $udetails->comp_person_name ?> 
<span class="user-status is-online"></span>

现在当我试图显示comp_person_name时,我得到了上述错误。 哪里出错了?

1 个答案:

答案 0 :(得分:0)

数据返回一个数组。所以替换

 $udetails->comp_person_name  

$udetails['0']->comp_person_name

解决了问题

相关问题