dory4404 2016-12-14 15:36 采纳率: 0%
浏览 135

我想使用2个不同的数据源进行分页

I want to pagination using 2 different data sources using PHP.

1, Mysql database

2, Text file

start pagination 1 page from MySQL database data and the end to text file data

Example: in start show data from MySQL DB and then when database data ends then show from text file

Example: 1 to 6 pages show data from db and after page 6 data show from text file

here is text file fetch code

Bro here is text file fetch code

function FetchUsernames(){
    $file_contents = file_get_contents('review_files/usernames.txt');
    $usernames  = explode("
",$file_contents);
    shuffle($usernames);
    return $usernames;
}

function FetchReviewTitles(){
    $file_contents = file_get_contents('review_files/review_titles.txt');
    $titles  = explode("
",$file_contents);
    shuffle($titles);
    return $titles;
}

function FetchReviews(){
    $file_contents = file_get_contents('review_files/reviews.txt');
    $reviews  = explode("|",$file_contents);
    shuffle($reviews);
    return $reviews;
}

function MergeTXTFilesData(){
  $FetchUsernames = FetchUsernames();
  $FetchReviewTitles = FetchReviewTitles();
  $FetchReviews = FetchReviews();

foreach ($FetchUsernames as $key => $username){
    if (isset($FetchReviewTitles[$key]) && isset($FetchReviews[$key])){
        $Reviews[$key]['username'] = $username;
        $Reviews[$key]['title'] = $FetchReviewTitles[$key];
        $Reviews[$key]['review'] = $FetchReviews[$key];
    }
}

return $Reviews;

and we fetched data from mysql and paginated

but now we need to merge pagination

  • 写回答

1条回答 默认 最新

  • qq_26126071 2022-01-04 18:41
    关注

    解决pagehelper不能对2个数据源分页问题。 解决2个都能返回分页数据api合并后的分页问题。 resolve pagehelper can't deal with 2 data's page problem, the first data will be showed page by page, and then the second。
    在github or gitee, search “pagemergehelper”

    评论

报告相同问题?

悬赏问题

  • ¥20 求自动化运维语料数据集
  • ¥30 广告检测流量作弊案例 IDEA运行代码报错 连接不上metastore 检测了环境配置没有问题 请求远程解决加VX问细节问题 不加的不回复
  • ¥15 matlab图像融合代码被嫌弃太简单,求改进。第一步改成直接读取三张图片,不读取文件夹
  • ¥20 微处理器原理与应用(私有偿)
  • ¥50 8051单片机关于ADC0809的应用
  • ¥15 有没有能拿来练练手写完发给我
  • ¥15 禁止修改windows系统时间
  • ¥50 kinect连接win11笔电导致音视频设备消失
  • ¥15 python线性查找题
  • ¥20 GDB info thread 显示格式问题