伪静态搜索出现问题,求帮忙

浏览:697 发布日期:2016/03/31 分类:求助交流 关键字: 搜索
使用的是3.2.3完整版    public function index() {
        // 分页
        $PageNum = 20;
        $T = M('news as a');
        //
        $map = array();
        $ClassId = I('get.ClassId', 0);
        if ($ClassId > 0) {
            $map['classid'] = array('eq', $ClassId);
            $this->ClassId = $ClassId;
        }
        $Keywords = I('get.Keywords','');
        if ($Keywords != '') {
            $map['title'] = array('like', '%' . $Keywords . '%');
            $this->Keywords = $Keywords;
        }
        $Count = $T->where($map)->count();
        echo $T->getLastSql() .'<br/>';
        $Page = getPage($Count, $PageNum);
        // 显示分页
        $show = $Page->show();
        $field = 'a.id,a.title,a.color,a.isbold,a.classId,a.isbest,b.CnName,a.img,a.hits,a.upTime';
        $datalist = $T->field($field)->join('left join ' . C('DB_PREFIX') . 'news_type as b on b.id = a.classid')->where($map)->order('upTime Desc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
        echo $T->getLastSql() .'<br/>';
        $this->assign('datalist', $datalist);
        $this->assign('page', $show);
        // 分类
        $this->assign('newstype', getTypeArr('news_type'));
        // show
        $this->display('index');
    }
配置文件里面是:'URL_MODEL' => 2
我使用搜索:
只能按ClassId分类搜索。。
使用:Keywords搜索,可以搜索第一页。但是翻页后不是搜索的结果了。我看URL里面是带了Keywords参数的。
我把配置文件里面:'URL_MODEL' => 0,才正常,其它的,1,3也不行。只有0可以。。
我打印的SQL语句是:
SELECT COUNT(*) AS tp_count FROM hl_news as a WHERE title LIKE '%微软%' LIMIT 1
SELECT a.id,a.title,a.color,a.isbold,a.classId,a.isbest,b.CnName,a.img,a.hits,a.upTime FROM hl_news as a left join hl_news_type as b on b.id = a.classid WHERE title LIKE '%微软%' ORDER BY upTime Desc LIMIT 0,20

第二页的URL是:
http://localhost:9600/Admin/News/index/ClassId/0/Keywords/微软/p/2.html
SQL语句是:
SELECT COUNT(*) AS tp_count FROM hl_news as a LIMIT 1
SELECT a.id,a.title,a.color,a.isbold,a.classId,a.isbest,b.CnName,a.img,a.hits,a.upTime FROM hl_news as a left join hl_news_type as b on b.id = a.classid ORDER BY upTime Desc LIMIT 20,20

是我哪里写错了。还是BUG?
最佳答案
评论() 相关
后面还有条评论,点击查看>>