fastadmin的无限极分类
时间:2023年07月02日
/来源:网络
/编辑:佚名
首先你需要引用
php复制代码use fast\Tree;
然后,你需要得到需要的值
php复制代码//查询条件:
$search = $this->request->request("search");
//查询类型
$type = $this->request->request("type");
//查询开始位置
$offset = $this->request->request("offset");
//每页查询限制
$limit = $this->request->request("limit");
然后我们就可以使用咯,开始
php复制代码//来先制造恐慌,开玩笑的,别当真
$list = [];
// 调用类的初始化方法
$tree = Tree::instance();
//给他赋予一个参数
//下面是本大人的解说时间
//$this->model->order('id desc')->select() 模型查询的对象
//collection(查询出来的对象)->toArray() 把对象转成数组
//$tree->init(数组,上级关系字段)
//当当当,就变成这样咯
// $tree->init(collection($this->model->order('id desc')->select())->toArray(), 'pid');
$tree->init(collection($this->model->order('id desc')->select())->toArray(), 'pid');
//getTreeArray获取数组,getTreeList 进行排序
//$tree->getTreeList(数组, 需要判断的字段)
$this->categorylist = $tree->getTreeList($tree->getTreeArray(0), 'name');
//好的打完收工咯,哈哈哈哈哈哈哈
//剩下的就交给你们了 晚安,亲
$categorydata = [0 => ['type' => 'all', 'name' => __('None')]];
foreach ($this->categorylist as $k => $v) {
$categorydata[$v['id']] = $v;
}
$total = count( $this->categorylist);
$result = array("total" => $total, "rows" => array_slice($this->categorylist,$offset,$limit));
php复制代码use fast\Tree;
然后,你需要得到需要的值
php复制代码//查询条件:
$search = $this->request->request("search");
//查询类型
$type = $this->request->request("type");
//查询开始位置
$offset = $this->request->request("offset");
//每页查询限制
$limit = $this->request->request("limit");
然后我们就可以使用咯,开始
php复制代码//来先制造恐慌,开玩笑的,别当真
$list = [];
// 调用类的初始化方法
$tree = Tree::instance();
//给他赋予一个参数
//下面是本大人的解说时间
//$this->model->order('id desc')->select() 模型查询的对象
//collection(查询出来的对象)->toArray() 把对象转成数组
//$tree->init(数组,上级关系字段)
//当当当,就变成这样咯
// $tree->init(collection($this->model->order('id desc')->select())->toArray(), 'pid');
$tree->init(collection($this->model->order('id desc')->select())->toArray(), 'pid');
//getTreeArray获取数组,getTreeList 进行排序
//$tree->getTreeList(数组, 需要判断的字段)
$this->categorylist = $tree->getTreeList($tree->getTreeArray(0), 'name');
//好的打完收工咯,哈哈哈哈哈哈哈
//剩下的就交给你们了 晚安,亲
$categorydata = [0 => ['type' => 'all', 'name' => __('None')]];
foreach ($this->categorylist as $k => $v) {
$categorydata[$v['id']] = $v;
}
$total = count( $this->categorylist);
$result = array("total" => $total, "rows" => array_slice($this->categorylist,$offset,$limit));
新闻资讯 更多
- 【建站知识】查询nginx日志状态码大于400的请求并打印整行04-03
- 【建站知识】Python中的logger和handler到底是个什么?04-03
- 【建站知识】python3拉勾网爬虫之(您操作太频繁,请稍后访问)04-03
- 【建站知识】xpath 获取meta里的keywords及description的方法04-03
- 【建站知识】python向上取整以50为界04-03
- 【建站知识】scrapy xpath遇见乱码解决04-03
- 【建站知识】scrapy爬取后中文乱码,解决word转为html 时cp1252编码问题04-03
- 【建站知识】scrapy采集—爬取中文乱码,gb2312转为utf-804-03