PHP Classes

File: test.php

Recommend this page to a friend!
  Classes of Igor Herson Aquino de França   Connection PDO connection and multi pagination   test.php   Download  
File: test.php
Role: Example script
Content type: text/plain
Description: test, examples and comments
Class: Connection PDO connection and multi pagination
Show links to browse query results using PDO
Author: By
Last change:
Date: 15 years ago
Size: 2,616 bytes
 

Contents

Class file image Download
<?php
/*
 * Created on 06/02/2009
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates

//SQL to test

CREATE TABLE IF NOT EXISTS `regiao` (
  `idregiao` int(11) NOT NULL auto_increment,
  `nome` varchar(45) default NULL,
  `codigo` varchar(45) default NULL,
  PRIMARY KEY (`idregiao`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=13 ;

--
-- Extraindo dados da tabela `regiao`
--

INSERT INTO `regiao` (`idregiao`, `nome`, `codigo`) VALUES
(1, 'REGIÃO METROPOLITANA', '1'),
(2, 'MATA SUL', '2'),
(3, 'AGRESTE SETENTRIONAL', '3'),
(4, 'AGRESTE CENTRAL', '4'),
(5, 'MATA NORTE', '5'),
(6, 'AGRESTE MERIDIONAL', '6'),
(7, 'MOXOTÓ', '7'),
(8, 'PAJEÚ', '8'),
(9, 'ITAPARICA', '9'),
(10, 'SERTÃO CENTRAL', '10'),
(11, 'SÃO FRANCISCO', '11'),
(12, 'ARARIPE', '12');
*/
 
 
include('dbconnection.class.php');
    
$db = new dbconnection;
    
//simple connection with the database
     //to select, delete, update and others query's
     //$var = $db->query("select * FROM regiao");
     //echo $var['nome']."<br />";
    
     //unlimited and no paginable loop
     //$var1 = $db->queryRow("select * FROM regiao");
     //foreach($var1 as $var){
     //echo $var['nome']."<br />";
     //}
    
     //naviagation by first letter of predefined field of the database
     //first param is the fiel
     //second param is a delimiter
    
$db->navLetters('nome', ' - ');
    
    
    
//limited loop
     //second param is the number of register per page
    
$var1 = $db->limitedQueryRow("select * FROM regiao", 6);
     foreach(
$var1 as $var){
     echo
$var['nome']."<br />";
     }
    
    
//jump to page
     //parameter to set label of the form, default is 'Jump to page:'
     //pages start with 0
    
$db->jumpToPage('JUMP');
    
    
//list links limited or unlimited, to limit links, set the param Ex: listLinks(2,' - ')
     //if you want unlimited links set 0 or don't set the first param, deafalt is space.
     //the second param is a delimitator between links.
    
$db->listLinks(3, ' - ');
    
    
//list links limited or unlimited, to limit links, set the param Ex: listLinks(2,' - ')
     //if you want unlimited links set 0 or don't set the first param, deafalt is space.
     //the second param is a delimitator between links.
     
$db->listPages(3, ' - ');
     
     
//navigation by links
      //param in order
      //First label, default is 'First'
      //Previous label, default is 'Previous'
      //Next label, default is 'Next'
      //Last label, default is 'Last'
      //delimiter, default is space
     
$db->navLinks('<<', '<', '>', '>>', ' - ');
    
?>