All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
delphi类中方法的使用技巧和实例
PHP动态网站制作中关于文件操作的疑难问答_php资料_编程技术
FCKeditor(asp.net)使用方法_[Asp.Net教程]
Asp.Net,Ajax,学习笔记13,AJAX,Library中异步通信层使用_[Asp.Net教程]
PHP将汉字转换拼音_[PHP教程]
掌握SQL四条最基本的数据操作语句_[SQL,Server教程]
ASP.NET中文显示之两种解决方法_[Asp.Net教程]
ASP.NET技巧:GridView控件自定义分页详解_.net资料_编程技术
开发环境下优化SQl语句的十个重要步骤_mssql学习_编程技术
GridView删除记录时增加确认提示框_[Asp.Net教程]
Reading number is top 10 pictures
教你22句话
[猫扑大杂烩]华东师范墙上看到的捐精告示 15毫升3600元
Black and white also sexy--YanLiu2
美丽的桂林风光1
NeedWallpaper5
Fierce chengdu woman, street rape man
每天进步一点点
China railway shunting skills competition
Sora aoi on twitter1
So beauty, will let you spray blood1
Download software ranking
实战黑客不求人
天龙八部十二宫服务端
打鸟视频
VeryCD电驴(EasyMule) V1.1.9 Build09081
WebService在.NET中的实战应用教学视频 → 第5集
都市狐狸姑娘传
致我们终将逝去的青春
Boxer vs Yellow1
XML+Web+Service开发教程
Tram sex maniac 2 (H) rar bag14
aaa published in(发表于) 2013/12/21 22:36:10 Edit(编辑)
分页显示Oracle数据库记录的PHP类_php资料_编程技术

分页显示Oracle数据库记录的PHP类_php资料_编程技术

分页显示Oracle数据库记录的PHP类_php资料_编程技术-你的首页-uuhomepage.com

  <?php

/*********************************************
TOracleViewPage v 2.0
日期:2000-9-23

分页显示Oracle数据库记录的类


更新日期:2000-10-19
增加显示TopRecord的功能,允许第一页显示的记录数与其它页不同。

作者:sharetop
email:ycshowtop@21cn.com

***********************************************/
class TOracleViewPage {

var $Table; //表名
var $MaxLine; //每页显示行数

var $LinkId; //数据库连接号
var $Id; //排序参考字段

var $Offset; //记录偏移量
var $Total; //记录总数
var $Number; //本页读取的记录数
var $TopNumber;//读新记录时实际取出的记录数
var $Result; //读出的结果
var $TopResult;//读新记录时的结果

var $TheFirstPage;//特殊指定第一页的链接
var $StartRec; //指定第二页的起始记录号

var $TPages; //总页数
var $CPages; //当前页数

var $TGroup;
var $PGroup; //每页显示的页号个数
var $CGroup;

var $Condition; //显示条件 如:where id='$id' order by id desc
var $PageQuery; //分页显示要传递的参数

//-------------------------------------
// 以下构造函数、析构函数及初始化函数
//-------------------------------------

//构造函数
//参数:表名、最大行数、分页参考的字段、每页显示的页号数

function TOracleViewPage($TB,$ML,$id){
global $offset;

$this->Table=$TB;
$this->MaxLine=$ML;
$this->Id=$id;

$this->StartRec=0;
if(isset($offset)) $this->Offset=$offset;
else $this->Offset=0;

$this->Condition="";
$this->TheFirstPage=NULL;
$this->PageQury=NULL;
}

//初始化
//参数:用户名、密码、数据库
function InitDB($user,$password,$db){
if (PHP_OS == "WINNT") $dllid=dl("php3_oci80.dll");
$this->LinkId = OCILogon($user,$password,$db);
}

//断开
function Destroy(){
OCILogoff($this->LinkId);
}

//-------------------------
// Set 函数
//-------------------------

//设置显示条件
//如:where id='$id' order by id desc
//要求是字串,符合SQL语法(本字串将加在SQL语句后)

function SetCondition($s){
$this->Condition=$s;
}

//设置每组的显示个数
function SetNumGroup($pg){
$this->PGroup=$pg;
}
//设置首页,如无则为NULL
function SetFirstPage($fn){
$this->TheFirstPage=$fn;
}
//设置起始记录,如无则取默认0
function SetStartRecord($org){
$this->StartRec=$org;
}

//设置传递参数
// key参数名 value参数值
// 如:setpagequery("id",$id);如有多个参数要传递,可多次调用本函数。

function SetPageQuery($key,$value){
$tmp[key]=$key; $tmp[value]=$value;
$this->PageQuery[]=$tmp;
}

//--------------------------------
// Get 函数
//--------------------------------

//取记录总数
function GetTotalRec(){

$SQL="SELECT Count(*) AS total FROM ".$this->Table." ".$this->Condition;

$stmt = OCIParse($this->LinkId,$SQL);
$bool = OCIExecute($stmt);
if (!$bool) {
echo "连接失败!";
OCILogoff($this->LinkId);
exit;
}
else {
OCIFetch($stmt);
$this->Total=OCIResult($stmt,1);
}
OCIFreeStatement($stmt);
}

//取总页数、当前页
function GetPage(){
$this->TPages=ceil($this->Total/$this->MaxLine);
$this->CPages=ceil($this->Offset/$this->MaxLine)+1;
}

//取总组数、当前组
function GetGroup() {
$this->TGroup=ceil($this->TPages/$this->PGroup);
$this->CGroup=ceil($this->CPages/$this->PGroup);
}

//--------------------------------
// 工作函数
//--------------------------------

//读取记录
// 主要工作函数,根据所给的条件从表中读取相应的记录
// 返回值是一个二维数组,Result[记录号][字段名]

function ReadList() {

$SQL="SELECT * FROM ".$this->Table." ".$this->Condition." ORDER BY ".$this->Id." DESC";

$stmt = OCIParse($this->LinkId,$SQL);
$bool = OCIExecute($stmt);
if (!$bool) {
echo "连接失败!";
OCILogoff($this->LinkId);
exit;
}
else {
$ncols = OCINumCols($stmt);
for ( $i = 1; $i <= $ncols; $i++ )
$column_name[$i] = OCIColumnName($stmt,$i);
$k=0;

for($j=0;$j<$this->StartRec+$this->Offset;$j++) OCIFetch($stmt);
for($j=0;$j<$this->MaxLine;$j++){
if(OCIFetch($stmt)){
$k++;
for($i=1;$i<=$ncols;$i++)
$temp[$column_name[$i]]=OCIResult($stmt,$i);
$this->Result[]=$temp;
}
else break;
}
$this->Number=$k;

}
OCIFreeStatement($stmt);
return $this->Result;
}

//读最新的记录
//topnum指定要读出的记录数

function ReadTopList($topnum){

$SQL="SELECT * FROM ".$this->Table." ".$this->Condition." ORDER BY ".$this->Id." DESC";

$stmt = OCIParse($this->LinkId,$SQL);
$bool = OCIExecute($stmt);
if (!$bool) {
echo "连接失败!";
OCILogoff($this->LinkId);
exit;
}
else {
$ncols = OCINumCols($stmt);
for ( $i = 1; $i <= $ncols; $i++ )
$column_name[$i] = OCIColumnName($stmt,$i);
$k=0;

for($j=0;$j<$topnum;$j++){
if(OCIFetch($stmt)){
$k++;
for($i=1;$i<=$ncols;$i++)
$temp[$column_name[$i]]=OCIResult($stmt,$i);
$this->TopResult[]=$temp;
}
else break;
}
$this->TopNumber=$k;

}
OCIFreeStatement($stmt);
return $this->TopResult;
}

//---------------------------
// 分页相关
//---------------------------

//显示当前页及总页数
//本函数在GetPage()后调用。
function ThePage() {
echo "第".$this->CPages."页/共".$this->TPages."页";
}

//显示翻页按钮
//此函数要在GetPage()函数之后调用
//显示下页、上页,并加上要传递的参数

function Page() {
$k=count($this->PageQuery);
$strQuery=""; //生成一个要传递参数字串
for($i=0;$i<$k;$i++){
$strQuery.="&".$this->PageQuery[$i][key]."=".$this->PageQuery[$i][value];
}

return $strQuery;
}

function PrePage($strQuery){
上一篇:变量的变量,PHP 和 ..v=$this->Offset-$this->MaxLine;
if(上一篇:变量的变量,PHP 和 ..v>=0)
echo "<A href=$PHP_SELF?offset=".上一篇:变量的变量,PHP 和 ..v.$strQuery." class=newslink>上一页</A>";
else if($this->TheFirstPage!=NULL)
echo "<A href=".$this->TheFirstPage." class=newslink>上一页</A>";
else echo "上一页";
}

function NexPage($strQuery){
$next=$this->Offset+$this->MaxLine;
$k=$this->Total-$this->StartRec;
if($next<$k)
echo "<A href=$PHP_SELF?offset=".$next.$strQuery." class=newslink>下一页</A>";
else
echo "下一页";
}

//------------------------------------
// 记录分组
//----------------------------------
//显示分组
function NumPage() {
$first=($this->CGroup-1)*($this->PGroup)+1;
$last=($first+$this->PGroup > $this->TPages)? ($this->TPages+1):($first+$this->PGroup);
$pr=($this->CGroup-2>=0)?( ($this->CGroup-2)*($this->PGroup)+1 ):(-1);
上一篇:变量的变量,PHP 和 ..v=($pr!=-1)?( ($pr-1)*$this->MaxLine):(0);
$ne=($this->CGroup*$this->PGroup+1<=$this->TPages)?($this->CGroup*$this->PGroup+1):(-1);
$next=($ne!=-1)?( ($ne-1)*$this->MaxLine):(0);

$k=count($this->PageQuery);
$strQuery=""; //生成一个要传递参数字串
for($i=0;$i<$k;$i++){
$strQuery.="&".$this->PageQuery[$i][key]."=".$this->PageQuery[$i][value];
}

if($first!=1)
echo "<A href=$PHP_SELF?offset=".上一篇:变量的变量,PHP 和 ..v.$strQuery." > << </a>";
for($i=$first;$i<$last;$i++) {
if($this->CPages!=$i){
$current=($i-1)*$this->MaxLine;
echo "<A href=$PHP_SELF?offset=".$current.$strQuery." >".$i."</a> ";
}
else echo "<font color=#e00729>".$i."</font> ";
}
if($ne!=-1)
echo "<A href=$PHP_SELF?offset=".$next.$strQuery." > >> </a>";
}

//******end class
}
?>




添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.