试图获取非对象的属性 [英] Trying to get property of non-object

查看:71
本文介绍了试图获取非对象的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将用户ID从一个视图传递到另一个视图,并显示相应ID的配置文件详细信息.但是,我没有显示配置文件详细信息,而是收到错误消息试图获取非对象的属性.

I'm trying to pass id of user from one view to another and display profile details of respective id.But instead of displaying profile details i get error message "trying to get property of non-object.

这是第一个视图

<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时,我遇到了上述错误. 我哪里出问题了?

Now when i trying to display comp_person_name , i get above said error. Where i went wrong?

推荐答案

data返回一个数组.因此替换

data returns an array .So replacing

 $udetails->comp_person_name  

$udetails['0']->comp_person_name

解决了问题

这篇关于试图获取非对象的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆