index

作者: xueyueshuai | 来源:发表于2023-12-04 15:30 被阅读0次
    /**
     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
     */
 // application/admin/library/traits/Backend.php -> index()
public function index()
    {
        //设置过滤方法
        $this->request->filter(['strip_tags', 'trim']);
        if (false === $this->request->isAjax()) {
            return $this->view->fetch();
        }
        //如果发送的来源是 Selectpage,则转发到 Selectpage
        if ($this->request->request('keyField')) {
            return $this->selectpage();
        }
        [$where, $sort, $order, $offset, $limit] = $this->buildparams();
        $list = $this->model
            ->where($where)
            ->order($sort, $order)
            ->paginate($limit);
        $result = ['total' => $list->total(), 'rows' => $list->items()];
        return json($result);
    }
public function index()
    {
        if ($this->request->isAjax())
        {
            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
            $total = $this->model
                ->with(["category"])
                ->where($where)
                ->order($sort, $order)
                ->count();
            $list = $this->model
                ->with(["category"])
                ->where($where)
                ->order($sort, $order)
                ->limit($offset, $limit)
                ->select();
            $result = array("total" => $total, "rows" => $list);

            return json($result);
        }
        return $this->view->fetch();
    }

相关文章

  • 【Elasticsearch】index [index] blo

    ES保存是报标题错误,大致意思是ES只允许读,不允许写。 1、排查问题 ES环境是通过docker部署,先找到es...

  • index

    In a land where no magic is present. A land where the str...

  • index

    selfindex A AngularJS-V1 系列Apache Tomcat 系列Appium 系列 B Ba...

  • Index

    唯一索引(UNIQUE):每一行的索引值都是唯一的(创建了唯一约束,系统将自动创建唯一索引) 主键索引:当创建表时...

  • INDEX

    本文集拟为治疗长时间碎片化阅读造成的知识体系和阅读能力退化而设。主要记录看过的书籍(包括专业书籍)的摘抄,体系,感...

  • index

    学院派黑客是我瞎起的名字。在我的定义里学院派黑客是一群经受过高等教育具有良好CS素养但是对现有教育体系和学术氛围嗤...

  • Index

    Index 是为了加速查询的速度,它是储存在数据库中的实实在在的数据结构。通过 Index 可以快速定位到数据库中...

  • index

    0 intro 0.1 type of pages sql server divides space(storag...

  • Index

    Mark#LinkDifficultyFrequency-3Longest Substring Without R...

  • Index

    1.4.1 Basic Slicing and Indexing 说明:元组索引其实就是方括号里添加索引 可以引发...

网友评论

      本文标题:index

      本文链接:https://www.haomeiwen.com/subject/pvfrgdtx.html