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

最近遇到了一个这样的问题。

起因是我的代码:

$user['order']=$order->alias('a')

    ->join('shop w','a.pid = w.id','left')
->where('a.userid',$data['id'])
->field('a.*,w.pic')
->select();
foreach ($user['order'] as $k=>$v){
  $user['order'][$k]['pic']=$this->img($v['pic']);
}
然后我查了下资料,是说在循环中产生的,要设置一个中间变量。
修改如下:
$user['order']=$order->alias('a')
->join('shop w','a.pid = w.id','left')
->where('a.userid',$data['id'])
->field('a.*,w.pic')
->select();
$res=$user['order'];
foreach ($res as $k=>$v){
$v['pic']=$this->img($v['pic']);
$res[$k]=$v;
}
$user['order']=$res;
 
posted @ 2019-12-03 16:33  做网站的菜鸟  阅读(2054)  评论(0编辑  收藏  举报