文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>phpcms2008自定义sql时分页错误

phpcms2008自定义sql时分页错误

时间:2009-02-23  来源:goto999

自定义sql时分页链接产生严重错误: 修订方法: 文件--include\global.func.php                840行 修改 function tag()函数 1,将参数$catid=0 改为 $ccatid=0; 2,在global 后增加 $catid 为全局变量 3,在调用pages 行数前加 $ccatid=($ccatid==0)?$catid:$ccatid; 4,修改调用pages函数传入参数$catid为$ccatid  

function tag($module, $template, $sql, $page = 0, $number = 10, $setting = array(), $ccatid = 0)
{
    global $db, $CATEGORY, $MODULE, $URLRULE, $PHPCMS, $MODEL,$catid;
    if($sql)
    {
        @include_once PHPCMS_ROOT.$MODULE[$module]['path'].'include/output.func.php';
        $offset = 0;
        if($page !== 0)
        {
            $page = max(intval($page), 1);
            $offset = $number*($page-1);
            $sql_count = preg_replace("/^SELECT([^(]+)\s*FROM(.+)(ORDER BY.+)$/i", "SELECT COUNT(*) AS `count` FROM\\2", $sql);
            $count = cache_count($sql_count);
            $urlruleid = isset($setting['urlruleid']) ? intval($setting['urlruleid']) : 0;
            $urlrule = $urlruleid > 0 ? $URLRULE[$urlruleid] : '';
            $ccatid=($ccatid===0)?$catid:$ccatid;
            $pages = pages($count, $page, $number, $urlrule, $setting, $ccatid);
        }
        $i = 0;
        $data = array();
        $result = $db->query("$sql LIMIT $offset, $number");
        while($r = $db->fetch_array($result))
        {
            $data[++$i] = $r;
        }
        $rows = $db->num_rows($result);
        $db->free_result($result);
    }
    else
    {
        $data = array();
        $number = $rows = $count = $page = 0;
        $pages = '';
    }
    require_once template($module, $template, 1);
    $func = '_tag_'.$module.'_'.$template;
    $func($data, $number, $rows, $count, $page, $pages, $setting);
}

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载