public static function getPagedRows($query, $tablename, $params, $config = [])
{
$countQuery = clone $query;
if (isset($params['SqlAttackSearch']) || isset($params['SqlLogSearch']) || isset($params['ErrorLogSearch'])) {
//$rownums['nums'] = $countQuery->count();
//在条件查询时不处理分页,给一个大概数
$rownums['nums'] = 10000000;
} else {
$rownums = Yii::$app->db->createCommand("select TABLE_ROWS nums from information_schema.TABLES where TABLE_SCHEMA='Tuandai_Log' and TABLE_NAME='" . $tablename . "'")->queryOne();
}
$pages = new Pagination(['totalCount' => $rownums['nums']]);
if (isset($config['pageSize'])) {
$pages->setPageSize($config['pageSize'], true);
}
$rows = $query->offset($pages->offset)->limit($pages->limit);
if (isset($config['orderBy'])) {
$rows = $rows->orderBy($config['orderBy']);
}
$rows = $rows->all();
$rowsLable = 'datas';
$pagesLable = 'pager';
if (isset($config['rows'])) {
$rowsLable = $config['rows'];
}
if (isset($config['pages'])) {
$pagesLable = $config['pages'];
}
$ret = [];
$ret[$rowsLable] = $rows;
$ret[$pagesLable] = $pages;
return $ret;
}