2020年9月

此方法虽然不是最好的,但可以应付差事,实现功能。

假定以下为控制器Atest.php

...//省略代码
//引入框架自带分页渲染类
use think\paginator\driver\Bootstrap;

class Atest extends BaseController
{
    //报名审核过渡页
    function articleList()
    {
        $pageNo = Request::param('page');
        //客户端传过来的分页
        $pageNumber = $pageNo ? $pageNo : '0';
        if($pageNumber > 0){
            $pageNumber_one = $pageNumber-1;
        } else {
            $pageNumber_one = 0;
        }
        $limit = 10;//每页显示条数
        $offset = $pageNumber_one * $limit;//查询偏移值
        $sql = "SELECT ...复杂的SQL脚本... limit $offset,$limit";
        $list = Db::query($sql);

        //查询的总条数
        $sqlTotal = "SELECT count(*) as count_num ...复杂的SQL脚本...";
        $counts = Db::query($sqlTotal);
        $count = count($counts);//因为获取的总数为数组类型,因此用count计算出总数
        //组合分页数据格式
        $pagernator = Bootstrap::make($list,$limit,$pageNumber,$count,false,['path'=>Bootstrap::getCurrentPath(),'query'=>request()->param()]);
        $page = $pagernator->render();
        // 获取分页显示
        View::assign(['list' => $list, 'page' => $page]);
        return View::fetch();
    }
}

模板调用不变:

{$page|raw}

为什么说这种解决办法不好呢?请看下面大佬的总结:

https://mp.weixin.qq.com/s/czppKCEZTeoRq9pUcyOPag

收藏备用,很优秀的js UI

传送门:http://www.ligerui.com/

LigerUI 是基于jQueryUI框架,其核心设计目标是快速开发、使用简单、功能强大、轻量级、易扩展。简单而又强大,致力于快速打造Web前端界面解决方案,可以应用于.net,jsp,php等等web服务器环境。

采用Echarts图表控件API根据情况修改。

    ... //省略代码

    //模拟后台数据,每组6条数据
    var res = [
        [22, 34, 5, 2, 45, 29],
        [34, 74, 21, 6, 55, 69],
        [76, 64, 20, 4, 75, 22],
        [42, 39, 65, 11, 41, 49],
    ];
    //定时器
    setInterval(function getRes() {
        //获取数组中的数据组,直实环境下此段省略
        var i = parseInt(Math.random() * res.length);
        //将获取到的数据赋值给图表`option`内的`data`数组
        option.series[0].data = res[i];
        //渲染数据
        myChart.setOption(option);
    }, 1000); //间隔1秒钟向后台请求数据

    ... //省略代码

Echarts传送门:https://echarts.apache.org/zh/index.html

第一步:我用的是宝塔环境,所以出现下面红色的提醒

1.png
    【图1】

第二步:将找到php.ini配置文件,宝塔环境直接在后台找即可,把环境中禁用的pcntl_signal_dispatch删除并保存。

2.png
    【图2】

结论:重启服务器再次输入图1中的校验,出现图2提示说明正常使用workerman环境了。

安装: fileinfo扩展。

删除:禁用函数:pcntl_alarpcntl_wait

如下图的提示,安装fileinfo扩展。

./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - topthink/think-worker v3.0.4 requires ext-fileinfo * -> the requested PHP extension fileinfo is missing from your system.
    - topthink/think-worker v3.0.3 requires ext-fileinfo * -> the requested PHP extension fileinfo is missing from your system.
    - topthink/think-worker v3.0.2 requires ext-fileinfo * -> the requested PHP extension fileinfo is missing from your system.
    - topthink/think-worker v3.0.1 requires ext-fileinfo * -> the requested PHP extension fileinfo is missing from your system.
    - topthink/think-worker v3.0.0 requires ext-fileinfo * -> the requested PHP extension fileinfo is missing from your system.
    - Installation request for topthink/think-worker ^3.0 -> satisfiable by topthink/think-worker[v3.0.0, v3.0.1, v3.0.2, v3.0.3, v3.0.4].

  To enable extensions, verify that they are enabled in your .ini files:
    - /www/server/php/73/etc/php.ini
  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

Installation failed, reverting ./composer.json to its original content.