Indirect modification of overloaded element of api\life\model\NewsModel has no effect


$newsModel = new NewsModel();
$result = $newsModel
   ->field('id,name,more,create_time,hits,good_count')
   ->order('id desc')
   ->page($page,10)
   ->select();
if($result){
   foreach ($result as $key=>$val){
       if (!empty($val['more']['thumbnail'])) {
           $val['more']['thumbnail'] = get_image_url($val['more']['thumbnail']);
       }
       if (!empty($val['more']['video'])) {
           $val['more']['video'] = get_image_url($val['more']['video']);
       }
       if (!empty($val['more']['audio'])) {
           $val['more']['audio'] = get_image_url($val['more']['audio']);
       }
       $result[$key] = $val;
   }
}


直接这样重新循环结果集时 会报一下错误

[8] ErrorException in NewsController.php line 37

Indirect modification of overloaded element of api\life\model\NewsModel has no effect


而如果先把结果集转成数组

$result = $newsModel
   ->field('id,name,more,create_time,hits,good_count')
   ->order('id desc')
   ->page($page,10)
   ->select()->toArray();

就不会出现这样的问题,不知道什么情况

来源: up61技术博客 欢迎分享 (QQ:529857614)

qq交流群:63739043 up61博客-php交流群

上一篇: PHP使用header方式实现文件下载功能
下一篇: The filename is not recognised as an OLE file