千家信息网

TP框架数组去重后分页

发表于:2024-11-18 作者:千家信息网编辑
千家信息网最后更新 2024年11月18日,$view = D('HistoryTest') ->alias("as a") ->join("qxy_test as b on a.object = b.id") ->field
千家信息网最后更新 2024年11月18日TP框架数组去重后分页
$view = D('HistoryTest')    ->alias("as a")    ->join("qxy_test as b on a.object = b.id")    ->field("b.title,b.id,a.uid")    ->order('a.id desc')    ->where("a.title like '%".$key."%'")    ->select();$view = $this->multi_unique($view);   //调用去重方法$count = count($view);$Page = new \Think\Page($count,5);  //每页显示条数$view = array_slice($view, $Page->firstRow,$Page->listRows);  //分组函数$show = $Page->show();                 //显示分页$this->sear = $view;    //发送变量$this->page = $show;public function multi_unique($array) {  //数组去重方法    foreach ($array as $k=>$na)        $new[$k] = serialize($na);    $uniq = array_unique($new);    foreach($uniq as $k=>$ser)        $data[$k] = unserialize($ser);    return ($data);}


0