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