Login   Register  
PHP Classes
elePHPant
Icontem

File: test1.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Andrioli Darvin  >  Yet Another Pager  >  test1.php  >  Download  
File: test1.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Yet Another Pager
Database row pager with edit and search support
Author: By
Last change: Fix the include statement
Date: 10 years ago
Size: 3,577 bytes
 

Contents

Class file image Download
<?php
/*
 * test1.php
 * Module yap testing program 1
 * $Header: d:/cvs/classistd/yap/test1.php,v 1.8 2004/04/27 21:12:06 Administrator Exp $
 */
// Include the msgbox class
include_once('CYapBox.php');
// the module itself
include_once('CYap.inc');
// The session are required, start it
session_start('test');
/*
 * Open the HTML page. The module make the html code to show the contents
 * but not open or close the page. The caller must provide the requireq code
 * to start and to close the page
 */
echo '<html><body>';
/*
 * Sql statement to retrieve the data to show. Two statement are required. The first
 * give the row to show, the second one allows to retrieve the number of rows
 * returned by tre previous sql statement.
 * Notice the 'where '. If you don't add condition (i.e 'where id>1'), you must add
 * the 'where' without any other condition (the module append to it the condition
 * that it get from the search box).
 * If you add some conditional statement you must end the statement with 'and'
 * (i.e '... where id>1 and ') to allow to append the required search patterns.
 */
$SelectQuery='select id, DEvent, errno, text, filename, line from dlog where ';
$SelectCount='select count(*) from dlog where ';
/*
 * Start to prepare the parameters for the module
 */
//Db Connection parameters
$db_info=array('servername'     => 'localhost',
               
'dbname'         => 'log',
               
'user'           => 'root',
               
'password'       => '',
               
'selectquery'    => $SelectQuery,
               
'selectcount'    => $SelectCount,
               
/* field to use to order the rows
                * it must 'selected' from $SelectQuery
                */
               
'orderfield'     => 'id'
                
/* order A=upward, D=descending*/
               
'orderdirection' => 'A',
               
/* should the module open the connection
                * to the database? */
               
'needopendb'     => true        
               
);
// Allow to search on the field DEvent and errno.
$Search_field=array(array('description' => 'Event Date',
                          
'fieldname'   => 'DEvent',
                          
/* A=alphabetic, N=Numeric */
                          
'type'        => 'A',
                          
'size'        => 14,
                          
/* use regex to match the field
                           * contents against the requested
                           * string */
                          
'useregex'   => ),
                    array(
'description' => 'Error Code',
                          
'fieldname'   => 'errno',
                          
'type'        => 'N'),
                    );
// Fields to show for each row
$Show_field=array(array('fieldname' => 'id',
                        
'header'    => 'Id'),
                  array(
'fieldname' => 'DEvent',
                        
'header'    => 'Event Date'),
                  array(
'fieldname' => 'errno',
                        
'header'    => 'Error Code'),
                  array(
'fieldname' => 'text',
                        
'header'    => 'Description'),
                  );

$Show_info=array('prefix' => 'tst1',
                  
'showdethref' => true);
// I don't setup the detail mode, the add/modify/delete row functions
$Modify_info=array();

// new class istance
$p=new CYap($Search_field$Show_field$db_info$Show_info$Modify_info);
// Show it
$p->showpage();
echo 
'</body></html>';
// That's all folk!
?>