简体   繁体   English

试图获取对象上的非对象错误的属性

[英]Trying to get property of non-object error on object

I'm getting the following error reports: 我收到以下错误报告:

Severity: Notice 严重程度:注意
Message: 信息:
Trying to get property of non-object 试图获取非对象的属性

Using gettype() I can see that it's a proper object. 使用gettype()可以看到它是一个正确的对象。

A print_r() returns: print_r()返回:

stdClass Object ( [campaigngroupid] => 3 [name] => And another one [dt_created] => 2014-02-04 17:11:21 [created_userid] => 1 [deleted] => 0 )

Echoing out $object->name for example works fine, but still, I'm getting this notice... 例如,回显$object->name效果很好,但是我仍然收到此通知...

The object is set using CodeIgniter's ->row() from a database query result. 使用CodeIgniter的->row()从数据库查询结果中设置对象。

All I can ask is, sup? 我能问的是

Try this in your model, Suppose $query holds the query object: 在您的模型中尝试一下,假设$ query保存了查询对象:

 function some_model_function(){
     ..........
     ..........
     if($query->num_rows() > 0 ){
        return $query->row();
     }
     return FALSE;
 }

Also check whether the notice is from any where else. 同时检查通知是否来自其他地方。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM