One of the Oracle database record classes displayed by page _ PHP Tutorial

Source: Internet
Author: User
One of the Oracle database record classes displayed on pages. <? Php *************************************** * ***** TOracleViewPagev2.0 date: -9-23 display the Oracle database record class Update Date by page: 2000-10-19 add display TopReco <? Php

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

Categories of Oracle Database records displayed on pages


Updated on: 2000-10-19
Added the TopRecord display function, allowing the number of records displayed on the first page to be different from those displayed on other pages.

Author: sharetop
Email: ycshowtop@21cn.com

**************************************** *******/
Class TOracleViewPage {

Var $ Table; // Table name
Var $ MaxLine; // number of lines per page

Var $ LinkId; // Database Connection number
Var $ Id; // sorting reference field

Var $ Offset; // record Offset
Var $ Total; // The Total number of records.
Var $ Number; // Number of records read on the current page
Var $ TopNumber; // number of records actually retrieved when reading a new record
Var $ Result; // read the Result
Var $ TopResult; // the result when the new record is read.

Var $ TheFirstPage; // specify the link to the first page.
Var $ StartRec; // specify the start record number on the second page

Var $ TPages; // The total number of pages.
Var $ CPages; // Current page number

Var $ TGroup;
Var $ PGroup; // 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; // display the parameters to be passed by page
//-------------------------------------
// The following constructor, destructor, and initialization function
//-------------------------------------

// Constructor
// Parameter: table name, maximum number of rows, reference fields by page, number of page numbers 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
// Parameter: 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
//-------------------------

// Set display conditions
// For example, where id = '$ ID' order by id desc
// It must be a string that complies with the SQL syntax (this string will be added after the SQL statement)

Function SetCondition ($ s ){
$ This-> Condition = $ s;
}

// Set the display quantity for each group
Function SetNumGroup ($ pg ){
$ This-> PGroup = $ pg;
}
// Set the homepage. if not, the homepage is NULL.
Function SetFirstPage ($ fn ){
$ This-> TheFirstPage = $ fn;
}
// Set the start record. If no record exists, the default value is 0.
Function SetStartRecord ($ org ){
$ This-> StartRec = $ org;
}

// Set transfer parameters
// Key parameter name value
// For example, setpagequery ("id", $ id). you can call this function multiple times if multiple parameters are to be passed.

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

// Retrieve 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 );
}

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

// Obtain the total number of groups and the current group
Function GetGroup (){
$ This-> TGroup = ceil ($ this-> TPages/$ this-> PGroup );
$ This-> CGroup = ceil ($ this-> CPages/$ this-> PGroup );
}

Http://www.bkjia.com/PHPjc/314257.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/314257.htmlTechArticle? Php /************************************** * ****** TOracleViewPagev 2.0 date: -9-23 display the Oracle database record class Update Date on pages: 2000-10-19 add display TopReco...

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.