Pagination displays one of the classes of Oracle database records

Source: Internet
Author: User
Tags date bool key reference stmt table name oracle database
oracle| Pagination | data | database | Display <?php

/*********************************************
Toracleviewpage v 2.0
Date: 2000-9-23

Pagination displays classes for Oracle database records


Renew Date: 2000-10-19
Increases the ability to display Toprecord, allowing the first page to display a different number of records than other pages.

Author: sharetop
Email:ycshowtop@21cn.com

***********************************************/
Class Toracleviewpage {

var $Table; Table name
var $MaxLine; Show number of rows per page

var $LinkId; Database connection number
var $Id; Sort Reference Field

var $Offset; Record offset
var $Total; Total Records
var $Number; Number of records read on this page
The number of records actually taken out when a new record was read by Var $TopNumber;
var $Result; read out the results
var $TopResult//Results when reading a new record

var $TheFirstPage;//special Specifies the link for the first page
var $StartRec; Specify the starting record number for the second page

var $TPages; Total pages
var $CPages; Current page

var $TGroup;
var $PGroup; Number of page numbers displayed per page
var $CGroup;

var $Condition; Display criteria such as: where id= ' $id ' ORDER by id DESC
var $PageQuery; Pagination shows the parameters to pass
//-------------------------------------
The following constructors, destructors, and initialization functions
//-------------------------------------

Constructors
Parameters: Table name, maximum number of rows, paged Reference field, page number per 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;
}

Class
Parameters: User name, password, database
function Initdb ($user, $password, $db) {
if (Php_os = = "WINNT") $dllid =dl ("Php3_oci80.dll");
$this->linkid = Ocilogon ($user, $password, $db);
}

Disconnect
function Destroy () {
Ocilogoff ($this->linkid);
}
//-------------------------
Set function
//-------------------------

Setting Display conditions
such as: where id= ' $id ' ORDER by id DESC
The requirement is a string that conforms to the SQL syntax (this string will be added to the SQL statement)

function Setcondition ($s) {
$this->condition= $s;
}

Set the number of displays per group
function Setnumgroup ($PG) {
$this->pgroup= $pg;
}
Set the first page, if none is null
function Setfirstpage ($FN) {
$this->thefirstpage= $FN;
}
Set start record, if none, default 0
function Setstartrecord ($org) {
$this->startrec= $org;
}

Setting Pass Parameters
Value of key parameter name value
such as: Setpagequery ("id", $id), if you have more than one parameter to pass, you can call this function multiple times.

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

Total number of records taken
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);
}

Take total number of pages, current page
function GetPage () {
$this->tpages=ceil ($this->total/$this->maxline);
$this->cpages=ceil ($this->offset/$this->maxline) +1;
}

Take total group number, current group
function Getgroup () {
$this->tgroup=ceil ($this->tpages/$this->pgroup);
$this->cgroup=ceil ($this->cpages/$this->pgroup);
}



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.