Introduction: Paging thinkphp package or good use, but when there is a query packet group operation, it will not display tab variable
Now the reason I can not explain, and so on in order to make up later
First directly on the solution
$pageData = Db::table('tbl_distraction_buy_log')->alias('d')
->join('__OLDMAN__ o','d.oldman_id = o.oldman_id','left')
->join('__SERVICE__ s','d.service_id = s.service_id','left')
->where($where)
->order('d.add_time desc')
->group('d.oldman_id')
->field('o.oldman_id,o.name as oldman_name,sum(d.project_num) as num_buy')
->buildSql();
$pageData = Db::table($pageData)->alias('d2')->paginate($this->_pagesize, false, ['query' => request()->param()]);
$this->assign('page',$pageData->render());
Precautions: These are found when printing debugging
- The first is the need to use buildSql ()
- The second is the use of the constructed sub-queries, to rename a renewed, otherwise it will report a syntax error, and to consider the sub-query in the renaming distinction
- Another point is recommended (performance optimization): tp controller model and framework to make use of Db class static call