最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

fleaphp常用方法分頁之Pager使用方法

 更新時間:2011年04月23日 20:05:35   作者:  
fleaphp常用方法分頁之Pager使用方法,需要的朋友可以參考下。
Pager 分頁函數(shù)
復(fù)制代碼 代碼如下:

/**
* 構(gòu)造函數(shù)
*
* 如果 $source 參數(shù)是一個 TableDataGateway 對象,則 FLEA_Helper_Pager 會調(diào)用
* 該 TDG 對象的 findCount() 和 findAll() 來確定記錄總數(shù)并返回記錄集。
*
* 如果 $source 參數(shù)是一個字符串,則假定為 SQL 語句。這時,F(xiàn)LEA_Helper_Pager
* 不會自動調(diào)用計算各項分頁參數(shù)。必須通過 setCount() 方法來設(shè)置作為分頁計算
* 基礎(chǔ)的記錄總數(shù)。
*
* 同時,如果 $source 參數(shù)為一個字符串,則不需要 $conditions 和 $sortby 參數(shù)。
* 而且可以通過 setDBO() 方法設(shè)置要使用的數(shù)據(jù)庫訪問對象。否則 FLEA_Helper_Pager
* 將嘗試獲取一個默認(rèn)的數(shù)據(jù)庫訪問對象。
*
* @param TableDataGateway|string $source
* @param int $currentPage
* @param int $pageSize
* @param mixed $conditions
* @param string $sortby
* @param int $basePageIndex
*
* @return FLEA_Helper_Pager
*/
function FLEA_Helper_Pager(& $source, $currentPage, $pageSize = 20, $conditions = null, $sortby = null, $basePageIndex = 0)
{
$this->_basePageIndex = $basePageIndex;
$this->_currentPage = $this->currentPage = $currentPage;
$this->pageSize = $pageSize;
if (is_object($source)) {
$this->source =& $source;
$this->_conditions = $conditions;
$this->_sortby = $sortby;
$this->totalCount = $this->count = (int)$this->source->findCount($conditions);
$this->computingPage();
} elseif (!empty($source)) {
$this->source = $source;
$sql = "SELECT COUNT(*) FROM ( $source ) as _count_table";
$this->dbo =& FLEA::getDBO();
$this->totalCount = $this->count = (int)$this->dbo->getOne($sql);
$this->computingPage();
}
}

Pager 參數(shù)說明
$source 數(shù)據(jù)庫操作類
$currentPage 當(dāng)前頁
$pageSize 每頁顯示記錄數(shù)量
$conditions 查詢條件
$sortby 排序方式
$basePageIndex 頁碼基數(shù)
Pager 使用示例(實例)
復(fù)制代碼 代碼如下:

$dirname = dirname(__FILE__);
define('APP_DIR', $dirname . '/APP');
define('NO_LEGACY_FLEAPHP', true);
require($dirname.'/FleaPHP/FLEA/FLEA.php');
//設(shè)置緩存目錄
FLEA::setAppInf('internalCacheDir',$dirname.'/_Cache');
//鏈接數(shù)據(jù)庫
$dsn = array(
'driver' => 'mysql',
'host' => 'localhost',
'login' => 'root',
'password' => '',
'database' => 'wordpress'
);
FLEA::setAppInf('dbDSN',$dsn);
//讀取wp_posts的內(nèi)容
FLEA::loadClass('FLEA_Db_TableDataGateway');
FLEA::loadClass('FLEA_Helper_Pager');
//FLEA::loadHelper('pager');
class Teble_Class extends FLEA_Db_TableDataGateway {
var $tableName = 'wp_posts';
var $primaryKey = 'ID';
}
$tableposts =& new Teble_Class();
$pager =& new FLEA_Helper_Pager($tableposts,2,5);
$page = $pager->getPagerData();
print_r($page);

getPagerData 返回一些數(shù)據(jù)供調(diào)用
復(fù)制代碼 代碼如下:

$data = array(
'pageSize' => $this->pageSize,
'totalCount' => $this->totalCount,
'count' => $this->count,
'pageCount' => $this->pageCount,
'firstPage' => $this->firstPage,
'firstPageNumber' => $this->firstPageNumber,
'lastPage' => $this->lastPage,
'lastPageNumber' => $this->lastPageNumber,
'prevPage' => $this->prevPage,
'prevPageNumber' => $this->prevPageNumber,
'nextPage' => $this->nextPage,
'nextPageNumber' => $this->nextPageNumber,
'currentPage' => $this->currentPage,
'currentPageNumber' => $this->currentPageNumber,
);

相關(guān)文章

  • php實現(xiàn)zip文件解壓操作

    php實現(xiàn)zip文件解壓操作

    這篇文章主要介紹了php實現(xiàn)zip文件解壓操作的函數(shù)代碼,每一條函數(shù)代碼都有對應(yīng)的文字注釋,需要的朋友可以參考下
    2015-11-11
  • php記錄日志的實現(xiàn)代碼

    php記錄日志的實現(xiàn)代碼

    php記錄日志的實現(xiàn)代碼,主要分為幾種模式,需要的朋友可以參考下。
    2011-08-08
  • PHP基于自定義函數(shù)生成笛卡爾積的方法示例

    PHP基于自定義函數(shù)生成笛卡爾積的方法示例

    這篇文章主要介紹了PHP基于自定義函數(shù)生成笛卡爾積的方法,結(jié)合具體實例形式分析了php使用數(shù)組運算模擬集合實現(xiàn)笛卡爾積運算的相關(guān)操作技巧,需要的朋友可以參考下
    2017-09-09
  • 最新評論

    那坡县| 漯河市| 衢州市| 方正县| 高尔夫| 晋州市| 东宁县| 吉木萨尔县| 沙洋县| 中方县| 宁阳县| 山阴县| 壤塘县| 华坪县| 郴州市| 商都县| 合水县| 辉南县| 易门县| 本溪市| 山丹县| 奉新县| 罗源县| 确山县| 锡林郭勒盟| 江孜县| 深州市| 北碚区| 松桃| 万年县| 海伦市| 台中市| 大冶市| 天峻县| 武功县| 庆元县| 宁南县| 会理县| 化隆| 镶黄旗| 全南县|