最近遇到了一个这样的问题。
起因是我的代码:
$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;