這篇文章介紹的內容是關於TP5-分頁類別中的each函數 ,有著一定的參考價值,現在分享給大家,有需要的朋友可以參考一下
$list = Db::name('merchant_order_detail')->alias('a')->join('merchant_order b', 'b.id = a.order_id')->where($whereStr)->field($file)->order($order)->paginate(Config::get('list_rows'), false, ['page' => $page,'query'=>$param])->each(function($item, $key){ $item['loglist'] = Db::name('merchant_order_detail_log')->where("order_detail_id=".$item['id']." and amount>0")->field('order_sn')->select(); return $item; });
$list = Db::name('merchant_order')->alias('a') ->join('merchant_member mm', 'mm.id=a.member_id', 'LEFT') ->where($whereStr) ->field($file) ->order(['a.create_time' => 'desc']) ->paginate(Config::get('list_rows'), false, ['page' => $page,'query'=>$param]) ->each(function($item,$key){ if($item['pid'] == 0) { $item['company_name'] = Db::name('merchant')->where(['member_id'=>$item['member_id']])->value('company_name'); $item['sub_company_name'] = Db::name('merchant')->where(['member_id'=>$item['member_id']])->value('sub_company_name'); $item['corporation'] = Db::name('merchant')->where(['member_id'=>$item['member_id']])->value('corporation'); } else { $item['company_name'] = Db::name('merchant')->where(['member_id'=>$item['pid']])->value('company_name'); $item['sub_company_name'] = Db::name('merchant')->where(['member_id'=>$item['pid']])->value('sub_company_name'); $item['corporation'] = Db::name('merchant')->where(['member_id'=>$item['pid']])->value('corporation'); } return $item; });
$merchant_member_list = Db::name('merchant_member')->alias('mm') ->join('merchant m', 'm.member_id = mm.id', 'LEFT') ->join('merchant_type mt', 'm.merchant_type_id = mt.id', 'LEFT') ->where($where) ->field($field) ->order(['mm.is_lock' => 'asc','mm.create_time' => 'desc']) ->paginate(Config::get('list_rows'), false, ['page' => $page, 'query' => $param]) ->each(function($item, $key){ if($item['mt_pid']=='0'){ $item['cate'] = '一级'; } else { $item['cate'] = Db::name('merchant_type')->where("id=".$item['mt_pid'])->value('name'); } return $item; });
相關推薦:
以上是TP5-分頁類別中的each函數的詳細內容。更多資訊請關注PHP中文網其他相關文章!