yii2 oracle 原生sql分页
阅读原文时间:2023年07月15日阅读:2

$sql_list = "SELECT ID, FID, INSID,
FLIGHTNO, DEPNAME, ARRNAME,
to_char(DEPDATE,'yyyy-MM-dd HH24:mi') as DEPDATE,
CHECKID,CERTNAME,CERTTYPE, CERTNO, MOBILE, PRODUCTNAME, PRICE, TOTAL,
ETN,
DEP,ARR,
PAYSTATUS,OSTATUS,
to_char(CREATE_TIME,'yyyy-MM-dd HH24:mi') as CREATE_TIME FROM wx_checkin_insure
where 1=1 and {$time_condition} {$condition_sql}";
$dataProvider = new SqlDataProvider([
'sql' => $sql_list,
'params' => [':status' => 1],
'totalCount' => $total,
'sort' => [
'attributes' => [
'age',
'name' => [
'desc' => ['CREATE_TIME' => SORT_DESC],
],
],
],
'pagination' => [
'pageSize' => $limit,
'totalCount' => $total
],
]);
$dataProvider->getPagination()->setPage(当前页码-1);
$this->_data['offset'] = $dataProvider->getPagination()->offset;
$litst = $dataProvider->getModels();

    $this->\_data\['page\_data'\]  = $litst; // 分页数据  
    $this->\_data\['page\_total'\] = $dataProvider->getPagination()->getPageCount(); // 总共页数  
    $this->\_data\['page'\]       = $page;  
    $this->\_data\['limit'\] = $limit;