日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

BluePage通用分頁類助開發(fā)者提高開發(fā)效率(2)_PHP教程

編輯Tag賺U幣
教程Tag:暫無Tag,歡迎添加,賺取U幣!

推薦:解決setcookie語句問題的方法
解決辦法: 打開php_ini,搜索output_bufferfing,把前面的分號去掉,把off修改為on,或者設(shè)置一個(gè)數(shù)值。就可以了。 這類語句,造成這個(gè)原因是因?yàn)閟etcookie語句的問題。 cookie本

以下為引用的內(nèi)容:
<?php
include ( "lib/BluePage.class.php" ) ;
$pBP = new BluePage ;
$intCount = 1000 ; // 假設(shè)記錄總數(shù)為1000
$intShowNum = 10 ; // 每頁顯示10
$pBP->_getlink = false ; // 取消取得鏈接
$pBP->_getqs = false ; // 取消取得Query String
//返回分頁數(shù)字(省資源)
$aPDatas = $pBP->get( $intCount, $intShowNum );
//print_r($aPDatas); //打印出來看看

 

//只要最大頁,上一頁,與下一頁和當(dāng)前頁以及offset返回(最省資源)
$aPDatas = $pBP->get( $intCount, $intShowNum , 0 );
//print_r($aPDatas); //打印出來看看
?>


取得offset

以下為引用的內(nèi)容:

<?php
include ( "lib/BluePage.class.php" ) ;
$pBP = new BluePage ;
$intCount = 1000 ; // 假設(shè)記錄總數(shù)為1000
$intShowNum = 10 ; // 每頁顯示10
$aPDatas = $pBP->get( $intCount, $intShowNum );
$offset = $aPDatas['offset'] ;
?>


非數(shù)據(jù)庫分頁:

比如有一篇文章長度是10000字節(jié),要想每2000字節(jié)分為一頁,那怎么辦呢?

以下為引用的內(nèi)容:

<?php
include ( "lib/BluePage.class.php" ) ;
$pBP = new BluePage ;
$strLen = strlen($strSubContent); //假設(shè)內(nèi)容總長度,這個(gè)自己計(jì)算取得
$strSubLen = 2000 ; // 每頁數(shù)據(jù)長度
$aPDatas = $pBP->get( $strLen, $strSubLen );
$offset = $aPDatas["offset"] ;
//取得當(dāng)前頁的內(nèi)容
$strSubContent = fn_substr( $strSubContent, $offset , $strSubLen ) ; //截取函數(shù)自己寫
?>

一些屬性:

8.1 你使用的變量不是page,而是其他,比如是 pn :

以下為引用的內(nèi)容:

<?php
$pBP->_var = 'pn' ;
$aPDatas = $pBP->get( $intCount, $intShowNum );
?>

8.2 $this->_prefix有什么作用?

當(dāng)你的分頁是類似于page=pp123這樣的數(shù)字前面有字符的時(shí)候,$this->_prefix就有用了

以下為引用的內(nèi)容:
<?php
$pBP->_prefix = 'pp' ; // 如page=pp123的 pp
$aPDatas = $pBP->get( $intCount, $intShowNum );
?>

8.3 $this->_postfix有什么作用? :

當(dāng)你的分頁是類似于page=123p這樣的數(shù)字后面有字符的時(shí)候,$this->_postfix就有用了

以下為引用的內(nèi)容:

<?php
$pBP->_postfix = 'p' ; // 如page=123p的 p
$aPDatas = $pBP->get( $intCount, $intShowNum );
?>


8.4 $this->_prefix和$this->_postfix能否同時(shí)使用? :

當(dāng)然可以。當(dāng)你的分頁是類似于page=pn123ccc 這樣的數(shù)字后面有字符的時(shí)候,就兩個(gè)一起用

以下為引用的內(nèi)容:

<?php
$pBP->_prefix = 'pn' ;
$pBP->_postfix = 'ccc' ;
$aPDatas = $pBP->get( $intCount, $intShowNum );
?>

8.5 $this->_pos有什么用? :

它的作用是 當(dāng)前頁在分頁條中的位置設(shè)定,比如設(shè)為3,當(dāng)前頁是8,那么數(shù)字8就分處在分頁條的第三位即: 6 7 8 9 10 11 12 13 14 15

以下為引用的內(nèi)容:

<?php
$pBP->_pos = 5 ; //把當(dāng)前頁放到第五位
$aPDatas = $pBP->get( $intCount, $intShowNum );
?>


8.6 $this->_symbol有什么用? :

連接符

以下為引用的內(nèi)容:

<?php
$pBP->_symbol= '&' ; //使用&為鏈接符
$aPDatas = $pBP->get( $intCount, $intShowNum );
?>

8.7 $this->_getqs有什么用? :

是否取得Query String。默認(rèn)取得,為false則不取得�?晒�(jié)省資源,但如果要取得鏈接與html的時(shí)候,它會為true

以下為引用的內(nèi)容:

<?php
$pBP->_getqs = false ;
$aPDatas = $pBP->get( $intCount, $intShowNum );
?>


8.8 $this->_getlink有什么作用? :

this->_getlink默認(rèn)為true,即表示取得分頁的鏈接,為false時(shí),有關(guān)*ln鍵名的變量,都不會有值它的作用在于,1 適用于手工設(shè)置鏈接的人 2 節(jié)省資源

以下為引用的內(nèi)容:

<?php
$pBP->_getlink = false ;
$aPDatas = $pBP->get( $intCount, $intShowNum );
?>


8.9 $this->_encode有什么作用? :

$this->_encode默認(rèn)為true,即表示使用htmlspecialchars對Query String過濾

以下為引用的內(nèi)容:

<?php
$pBP->_encode= false ;//不過濾query string
$aPDatas = $pBP->get( $intCount, $intShowNum );
?>


最后:

關(guān)于BluePage.default.inc.php配置文件

這個(gè)是默認(rèn)的配置文件。你可以將面的內(nèi)容拷貝一份,保存為另一個(gè)配置。比如命名為page.abc.inc.php 假設(shè)當(dāng)前訪問的是list.php文件,在list.php同級目錄下有一目錄保存config,如./config目錄,而你將page.abc.inc.php保存在./config目錄了。

以下為引用的內(nèi)容:

<?php
$pBP->_encode= false ;//不過濾query string
$aPDatas = $pBP->get( $intCount, $intShowNum );
$strHtml = $pBP->getHTML( $aPDatas, './config/page.abc.inc.php' ); //路徑要正確
?>
 



請根據(jù)你的頁面輸出編碼,保存相應(yīng)編碼格式。就像你做模板一樣。

如果你的頁面是utf-8格式的,請保存配置文件為utf-8格式。注意,只是改page.abc.inc.php編碼,類文件的編碼請不要改動。

補(bǔ)充一點(diǎn):

如果覺得沒有取記錄總數(shù)的函數(shù)不方便,你可以自已在類里面加上取總數(shù)的函數(shù),或者使用外部函數(shù)

我們在實(shí)際應(yīng)用中,取記錄數(shù)的方法是跟隨項(xiàng)目對象的,所以一般不加在分頁類里面.

如果你沒有自己取記錄數(shù)的方法,你可以在分頁類中加上,或者加到外部

[php]

 

程序示例:

以下為引用的內(nèi)容:

<?php
//這是mysql的函數(shù),你可以加一個(gè)名為msGetCount的函數(shù)支持mssql
//加到類里面,或作為外部函數(shù)
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的函數(shù)
//加到類里面,或作為外部函數(shù)
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 ;

//作為外部函數(shù)時(shí)
$intCount = myGetCount( $strQuery , $dbconn ) ; //取得了記錄數(shù)
//如果是SQLserver
$intCount = msGetCount( $strQuery , $dbconn ) ; //取得了記錄數(shù)

//作為類的方法時(shí)
$intCount = $pBP->myGetCount( $strQuery , $dbconn ) ;//取得了記錄數(shù)
//如果是SQLserver
$intCount = $pBP->msGetCount( $strQuery , $dbconn ) ;//取得了記錄數(shù)

$pBP->get( $intCount, 10 ); //取得分頁數(shù)據(jù)
?>

當(dāng)然,我們并不鼓勵(lì)將數(shù)據(jù)庫操作放入分頁類中 。

分享:php上傳經(jīng)典源碼
以下為引用的內(nèi)容: function function_upload($name,$newname=,$dir=upload) { global $_FILES,$ext;

共2頁上一頁12下一頁
來源:模板無憂//所屬分類:PHP教程/更新時(shí)間:2009-09-03
相關(guān)PHP教程