yii2 oracle 原生sql分页

Posted 穆晟铭

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了yii2 oracle 原生sql分页相关的知识,希望对你有一定的参考价值。

   $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‘ => [
                ‘defaultPageSize‘ => $limit,
                ‘totalCount‘      => $total
            ],
        ]);
        $dataProvider->getPagination()->setPage(2);
        $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;

  

以上是关于yii2 oracle 原生sql分页的主要内容,如果未能解决你的问题,请参考以下文章

yii2之原生sql

sql Oracle代码片段

thinkphp5原生查询时,查询结果怎么分页,具体代码应该怎么写?

Yii2.0实现AJAX搜索分页

Yii2.0实现AJAX搜索分页

关于oracle分页顺序问题,我的代码可以实现分页,但是新添加进去的,顺序不是在最后