麻烦大佬支招,2 个数组合并后怎么翻页 [ 2.0 版本 ]
public function getxiaohei_top5() {
$a1=array();
$a2=array();
$a1=$this->sql->from('account')
->select(['id','name','beizhu'])
->where('`lock`= :lock',[':lock'=>1])
->limit(5)
->orderBy(['reg_date'=>SORT_DESC])
->all();
$a2=$this->sql->from('account')
->select(['id','name','beizhu'])
->where('`lock`= :lock',[':lock'=>1])
->limit(5)
->orderBy(['reg_date'=>SORT_DESC])
->all(Yii::$app->db2);
return array_merge($a1,$a2);//合并数组
}
public function getxiaohei() {
$sql = new \yii\db\Query();
$countu2 = $sql->from('account')
->where('`lock`= :lock',[':lock'=>1])->select('COUNT(*)')
->all();
$newspagination = new \yii\data\Pagination([
'totalCount'=> $countu2[0]['COUNT(*)'],
'defaultPageSize' => 20
]);
$sql2= new \yii\db\Query();
$info = $sql2->from('account')
->select(['id','name','beizhu'])
->where('`lock`= :lock',[':lock'=>1])
->limit($newspagination->limit)
->offset($newspagination->offset)
->orderBy(['reg_date'=>SORT_DESC])
->all();
return array($info,$newspagination);
}
共 2 个回答
yzg91
注册时间:2018-11-15
最后登录:2022-05-10
在线时长:22小时13分
最后登录:2022-05-10
在线时长:22小时13分
- 粉丝2
- 金钱479
- 威望20
- 积分899