thinkphp分页paginate获取可以foreach的数据


// 官网商品链接 public function index(){     $goods_name = I('goods_name'); // goods_name     $goodslist = Db::name('goods')->field('goods_id,goods_name,goods_content,endtime,shop_price,original_img')         ->where($where)         ->whereNull('delete_time')         ->paginate(25);              // 只需这样子就可以获取到可以循环的数组了     $data = $goodslist->all();          foreach($data as $k=>&$v){         $v['img'] = '_public_/'.$v['img'];                  // 直接付给上边的那个数组里         // 但是注意不能这样写 $goodslist[$k]['img'] = '_public_/'.$v['img']; 这样写不起作用                // 只能 再这样付给$goodslist数组才行         $goodslist[$k] = $v;     }    return $goodslist;     }

原文http://gongfuma.com/front/tech/detail/id/301/typeid/1.html


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM