标签:mod new res cat use element loaded each 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;
Indirect modification of overloaded element of api\life\model\NewsModel has no effect
标签:mod new res cat use element loaded each effect
原文地址:https://www.cnblogs.com/cici1989/p/11977758.html