2015-01-23 11:55:52 4006次浏览 1条回答 0 悬赏 0 金钱

求yii2的oracle分页代码,主要是Controller和View的代码,网上大部分都是mysql的,不知道oracle应该怎么处理,我发一段mysql的,请帮看看分页那里应该怎么改为oracle的。

Controller:

$sql = '
select * from (select UPDATETIME,F_ID,F_NAME,F_MPA,F_SPEC,F_MILL,F_PRICE,rank() over (partition by UPDATETIME order by F_ID) rn from T_MILL_PRICE1 ) t where rn=1
order by UPDATETIME desc';
$q = Yii::$app->db->createCommand($sql)->queryAll();
$pages = new Pagination([
    'defaultPageSize' => 50,
    'totalCount'=>count($q),
]);
$list = Yii::$app->db->createCommand($sql." limit ".$pages->limit." offset ".$pages->offset."")->queryAll();
$dataprovider = new ArrayDataProvider([
    'allModels' => $list,
]);
return $this->render('list',[
    'dataprovider'=>$dataprovider,
    '$pages'=>$pages,
]);

view:

<ul>
<?php foreach ($dataprovider as $country): ?>
    <li>
        <?= Html::encode("{$country->F_NAME} ({$country->F_MPA})") ?>:
        <?= $country->F_SPEC ?>
    </li>
<?php endforeach; ?>
</ul>
<?= LinkPager::widget(['pagination' => $pages]) ?>
您需要登录后才可以回答。登录 | 立即注册
ayurep
试用期

ayurep

注册时间:2014-11-24
最后登录:2015-09-22
在线时长:2小时51分
  • 粉丝1
  • 金钱10
  • 威望0
  • 积分30

热门问题