这个是默认的配置文件。你可以将面的内容拷贝一份,保存为另一个配置。比如命名为page.abc.inc.php 假设当前访问的是list.php文件,在list.php同级目录下有一目录保存config,如./config目录,而你将page.abc.inc.php保存在./config目录了。
<?php
$pBP->_encode= false ;//不过滤query string
$aPDatas = $pBP->get( $intCount, $intShowNum );
$strHtml = $pBP->getHTML( $aPDatas, './config/page.abc.inc.php' ); //路径要正确
?> |
请根据你的页面输出编码,保存相应编码格式。就像你做模板一样。
如果你的页面是utf-8格式的,请保存配置文件为utf-8格式。注意,只是改page.abc.inc.php编码,类文件的编码请不要改动。
补充一点:
如果觉得没有取记录总数的函数不方便,你可以自已在类里面加上取总数的函数,或者使用外部函数
我们在实际应用中,取记录数的方法是跟随项目对象的,所以一般不加在分页类里面.
如果你没有自己取记录数的方法,你可以在分页类中加上,或者加到外部
[php]
程序示例:
<?php
//这是mysql的函数,你可以加一个名为msGetCount的函数支持mssql
//加到类里面,或作为外部函数
function myGetCount( $strQuery , $pDBC )
{
$resResult = @mysql_query ( $strQuery , $pDBC ) ;
while ( $arrRow = @mysql_fetch_row ( $resResult ) )
{
$intCount = intval($arrRow[0]);
}
@mysql_free_result( $resResult ) ;
return $intCount ;
}
//这是SQLserver的函数
//加到类里面,或作为外部函数
function msGetCount( $strQuery , $pDBC )
{
$resResult = @mssql_query ( $strQuery , $pDBC ) ;
while ( $arrRow = @mssql_fetch_row ( $resResult ) )
{
$intCount = $arrRow[0];
}
@mssql_free_result( $resResult ) ;
return intval( $intCount ) ;
}
//使用例子
$dbconn = mysql_connect ( 'localhost' , 'dbname' , 'password' ) ;
mysql_select_db( 'yourdb' , $dbconn ) ;
$strQuery = 'SELECT COUNT(`id`) FROM TABLE WHERE 1' ;
include ( "lib/BluePage.class.php" ) ;
$pBP = new BluePage ;
//作为外部函数时
$intCount = myGetCount( $strQuery , $dbconn ) ; //取得了记录数
//如果是SQLserver
$intCount = msGetCount( $strQuery , $dbconn ) ; //取得了记录数
//作为类的方法时
$intCount = $pBP->myGetCount( $strQuery , $dbconn ) ;//取得了记录数
//如果是SQLserver
$intCount = $pBP->msGetCount( $strQuery , $dbconn ) ;//取得了记录数
$pBP->get( $intCount, 10 ); //取得分页数据
?> |
当然,我们并不鼓励将数据库操作放入分页类中
[/php]
主页地址:http://www.bluessoft.com/project/bluepage/
下载地址:http://www.bluessoft.com/project/bluepage/BluePage.tar.gz
9
7
3
1
2
3
4
8
: