Home > Backend Development > PHP Tutorial > One of the classes to display Oracle database records in pages_PHP tutorial

One of the classes to display Oracle database records in pages_PHP tutorial

WBOY
Release: 2016-07-21 16:10:31
Original
825 people have browsed it


<?php

/*******************************************
TOracleViewPagev 2.0
Date: 2000-9-23

Class for displaying Oracle database records in paging


Updated date: 2000-10-19
Add the function of displaying TopRecord, allowing the first This page displays a different number of records than other pages.

Author: sharetop
email:ycshowtop@21cn.com

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

var $Table; //Table name
var $MaxLine; //Display rows per page Number

var $LinkId; //Database connection number
var $Id; //Sort reference field

var $Offset; //Record offset
var $Total ; //Total number of records
var $Number; //Number of records read on this page
var $TopNumber; //Number of records actually taken out when reading new records
var $Result; //Read out The result
var $TopResult;//The result when reading a new record

var $TheFirstPage;//Specially specify the link of the first page
var $StartRec; //Specify the link of the second page Starting record number

var $TPages; //Total number of pages
var $CPages; //Current number of pages

var $TGroup;
var $PGroup; // The number of page numbers displayed on each page
var $CGroup;

var $Condition; //Display conditions such as: where id='$id' order by id desc
var $PageQuery; / /Paging displays the parameters to be passed
//-------------------------------------
//The following constructors, destructors and initialization functions
//--------------------------------- ------

//Constructor
//Parameters: table name, maximum number of rows, paging reference fields, page number displayed on each page

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;
}

//Initialization
//Parameters: username, password, database
function InitDB($user,$password,$db){
if (PHP_OS == " WINNT") $dllid=dl("php3_oci80.dll");
$this->LinkId = OCILogon($user,$password,$db);
}

//Break Open
function Destroy(){
OCILogoff($this->LinkId);
}
//------------------ ------
// Set function
//-------------------------

/ /Set display conditions
//For example: where id='$id' order by id desc
//The requirement is a string, conforming to SQL syntax (this string will be added after the SQL statement)

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

//Set the display number of each group
function SetNumGroup($pg) {
$this->PGroup=$pg;
}
//Set the home page, or NULL if none
function SetFirstPage($fn){
$this->TheFirstPage =$fn;
}
//Set the start record, if none, take the default of 0
function SetStartRecord($org){
$this->StartRec=$org;
}

//Set the transmission parameters
// key parameter name value parameter value
// For example: setpagequery("id",$id); If there are multiple parameters to be passed, you can add more Call this function times.

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

//Get the total number of records
function GetTotalRec(){

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

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

//Get the total number of pages and the current page
function GetPage(){
$this->TPages =ceil($this->Total/$this->MaxLine);
$this->CPages=ceil($this->Offset/$this->MaxLine)+1;
}

//Get the total number of groups, current group
function GetGroup() {
$this->TGroup=ceil($this->TPages/$this->PGroup) ;
$this->CGroup=ceil($this->CPages/$this->PGroup);
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/314257.htmlTechArticle<?php /******************** *********************** TOracleViewPagev 2.0 Date: 2000-9-23 Class for paging display of Oracle database records Update date: 2000-10-19 Added Show TopReco...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template