移动应用程序后在Codeigniter中出错

时间:2013-10-02 08:09:31

标签: php arrays codeigniter object

                    if ($query1->num_rows() > 0){
                        log_message('debug', 'Cert Found');
                        $result[$i]->cert = $query1->result()[0]->door_resource_url;
                    } else {
                        log_message('debug', 'Cert Not Found');
                        $result[$i]->cert = "no";
                    }

这个$query1->result()[0]正在抛出错误,但我不明白为什么因为它在我移动托管之前有效,现在我似乎无法解决这个问题。

任何人都知道我做错了什么?

1 个答案:

答案 0 :(得分:2)

是的,你托管的php版本很可能是< 5.4.0,添加function dereferencing时:

  

添加了函数数组解除引用,例如。 FOO()[0]。

所以你不能做$query1->result()[0]但你需要将它分配给变量并在那里引用它:

$temp = $query1->result();
$result[$i]->cert = $temp[0]->door_resource_url;