萬能的分頁類

2021-07-07 02:10:08 字數 4040 閱讀 1280

支援任意型別的分頁樣式

<?php

/* * to change this template, choose tools | templates

* and open the template in the editor.

*//**

* 分頁類

* 使用方式:

* $page = new page();

* $page->init(1000, 20);

* $page->setnotactivetemplate(' ');

* $page->setactivetemplate('');

* echo $page->show();

* *

* @author 風居住的地方

*/class page 總資料條數

* 每頁顯示條數

* 本頁開始條數

* 本頁結束條數

* 共有多少頁

* 首頁

* 尾頁

* 數字分頁

* 跳轉按鈕

*/private $template = '共有條資料

每頁顯示條資料,本頁-條資料

共有頁';

/*** 當前選中的分頁鏈結模板

*/private $activetemplate = '

'; /**

* 未選中的分頁鏈結模板

*/private $notactivetemplate = '

'; /**

* 顯示文字設定

*//**

* 初始化

* @param type $total 總條數

* @param type $pagesize 每頁大小

* @param type $param url附加引數

* @param type $pageparam 分頁變數

*/public function init($total, $pagesize, $param = '', $pageparam = 'page')

/*** 設定分頁模板

* @param type $template 模板配置

*/public function settemplate($template)

/*** 設定選中分頁模板

* @param type $activetemplate 模板配置

*/public function setactivetemplate($activetemplate)

/*** 設定未選中分頁模板

* @param type $notactivetemplate 模板配置

*/public function setnotactivetemplate($notactivetemplate)

/*** 返回分頁

* @return type

*/public function show() ',

'','',

'','',

'','',

'','',

'','',

), array(

$this->total,

$this->setpagesize(),

$this->star(),

$this->end(),

$this->pagenum,

$this->frist(),

$this->prev(),

$this->next(),

$this->last(),

$this->pagelist(),

$this->gopage(),

), $this->template);

}/**

* 獲取limit起始數

* @return type

*/public function getoffset()

/*** 設定limit

* @return type

*/private function setlimit() ";

}/**

* 獲取limit

* @param type $args

* @return type

*/public function __get($args) else

}/**

* 初始化當前頁

* @return int

*/private function setpage()

}return 1;

}/**

* 初始化url

* @param type $param

* @return string

*/private function geturi($param) else

}/**

* 本頁開始條數

* @return int

*/private function star() else

}/**

* 本頁結束條數

* @return type

*/private function end()

/*** 設定當前頁大小

* @return type

*/private function setpagesize()

/*** 首頁

* @return type

*/private function frist() &page=1", $this->config['frist'], true);

} else &page=1", $this->config['frist'], false);

}return $html;

}/**

* @return type

*/private function prev() else

return $html;

}/**

* 分頁數字列表

* @return type

*/private function pagelist() &page=", $page, false);

} else

}$linkpage .= $this->replace("&page=", $this->page, true);

for ($i = 1; $i <= $lastlist; $i++) &page=", $page, false);

} else

}return $linkpage;

}/**

* @return type

*/private function next() else

return $html;

}/**

* 最後一頁

* @return type

*/private function last() else

return $html;

}/**

* 跳轉按鈕

* @return string

*/private function gopage() " style="width:25px;"/>' . $this->pagenum . ')?' . $this->pagenum . ':this.previoussibling.value;location=\'' . $this->uri . '&page=\'+page+\'\'" value="go"/>';

return $html;

}/**

* 模板替換

* @param type $replace 替換內容

* @param type $result 條件

* @return type

*/private function replace($url, $text, $result = true) ', $url, $template);

$html = str_replace('', $text, $html);

return $html;

}}

python萬能分頁元件

usr bin env python from django.utils.html import mark safe class paginator object obj all userinfo.objects.all per page count 每頁顯示數量 show page count 顯...

萬能儲存過程分頁

引數說明 tblname 需要查詢的表名。如圖書表tblbooks 如果是多表 圖書表關聯圖書分類表 則寫成 tblbooks inner join tblbooktypes on tblbooks.bookid tblbooktypes.bookid fldname 主鍵欄位名 bookid li...

SQL萬能儲存過程分頁

alter proc dbo proc pager tablename varchar 50 表名 refieldsstr varchar 200 欄位名 全部欄位為 orderstring varchar 200 排序字段 必須 wherestring varchar 500 n 條件語句 不用加...