我有这个问题,其中我的模型返回一个对象,但是在控制器中它似乎找不到该字段时,我总是收到此错误“尝试获取非对象的属性”但是当我尝试 var_dump() 结果时从我的模型返回有值。我似乎无法理解为什么我无法访问它。它是否连接到活动记录?
以下是我的模型。
public function retrieve($user_id = FALSE)
{
if($user_id === FALSE)
{
$query = $this->db->get('login');
return $query->row();
}
else
{
$query = $this->db->get_where('login',array('account_id'=>$user_id));
return $query->result();
}
}
这是我的控制器的代码片段,我试图访问我的模型的部分
$this->load->model('account');
$acc = $this->account->retrieve($sess_userid);
var_dump($this->account->retrieve($sess_userid));
echo $acc->user_id;
注意 $sess_userid 有一个值。它是一个数字
有人对这个问题有想法吗?
更新
打印_r()
Array (
[0] => stdClass Object (
[account_id] => 2000005
[userid] => admin
[user_pass] => d033e22ae348aeb5660fc2140aec35850c4da997
[sex] => M
[email] => admin@ignitero.com
[group_id] => 99
[admin] => 1
[restrictions] => 0
[state] => 0
[unban_time] => 0
[expiration_time] => 0
[logincount] => 0
[lastlogin] => 0000-00-00 00:00:00
[last_ip] =>
[birthdate] => 0000-00-00
[character_slots] => 0
[pincode] =>
[pincode_change] => 0
)
)
var_dump()
array(1) {
[0]=> object(stdClass)#23 (18) {
["account_id"]=> string(7) "2000005"
["userid"]=> string(5) "admin"
["user_pass"]=> string(40) "d033e22ae348aeb5660fc2140aec35850c4da997"
["sex"]=> string(1) "M"
["email"]=> string(18) "admin@ignitero.com"
["group_id"]=> string(2) "99"
["admin"]=> string(1) "1"
["restrictions"]=> string(1) "0"
["state"]=> string(1) "0"
["unban_time"]=> string(1) "0"
["expiration_time"]=> string(1) "0"
["logincount"]=> string(1) "0"
["lastlogin"]=> string(19) "0000-00-00 00:00:00"
["last_ip"]=> string(0) ""
["birthdate"]=> string(10) "0000-00-00"
["character_slots"]=> string(1) "0"
["pincode"]=> string(0) ""
["pincode_change"]=> string(1) "0"
}
}