无法访问受保护的属性think \ Collection :: $ items

时间:2019-02-28 04:02:57

标签: php thinkphp

我正在使用TP5,遇到以下问题: 代码:

public function trust_export(){
$map = $this->getMap();
    $list_rows1 = input('list_rows');
    $listRows = isset($list_rows1)?$list_rows1:20;
    $order = $this->getOrder();
    if(empty($order)){
        $order='t.id desc';
    }
    $time=strtotime(date('y-m-d',time()));
    $xlsData = Db::view('...')
        ...
        ->order($order)->paginate($listRows);
    foreach($xlsData as $key=>$value){
        $xlsData->items->items[$key]['trust_date']=date('Y-m-d',$value['trust_date']);
    };
    ...
}

它抛出标题错误。 但是,在同一文件中,类似的功能可以正常工作,代码段如下:

public function temp_export(){
    $map = $this->getMap();
    $order = $this->getOrder();
    if(empty($order)){
        $order='t.id desc';
    }
    $list_rows1 = input('list_rows');
    $listRows = isset($list_rows1)?$list_rows1:20;
    $xlsData = Db::view(...)
        ->order($order)
        ->paginate($listRows);
    foreach($xlsData as $key=>$value){
    $xlsData->items->items[$key]['trust_date']=date('Y-m-d',$value['trust_date']);
        };
       ...
}

0 个答案:

没有答案