Login   Register  
PHP Classes
elePHPant
Icontem

File: index.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Marius Zadara  >  Query Paginator  >  index.php  >  Download  
File: index.php
Role: Example script
Content type: text/plain
Description: Script demo
Class: Query Paginator
Retrieve MySQL query results split in pages
Author: By
Last change:
Date: 2010-04-03 05:56
Size: 874 bytes
 

Contents

Class file image Download
<?php 

require_once('_includes/_includeAll.php');

// get a database connection
$dbConnection = @mysql_connect("localhost""root""");

if (!
$dbConnection)
    die(
"Could not connect to database");
    
// select the table
mysql_select_db("mysql"$dbConnection);


try
{
    
$qp = new QueryPaginator();
    
    
$qp->setConnection($dbConnection);
    
$qp->setResultsPerPage(50);

    
// set the run
    
$qp->setQuery("SELECT * FROM help_relation");
    
    
// while some records are still available ...
    
while ($qp->hasNext())
    {
        
// get the current rows in the associative format
        
$rows $qp->next(MYSQL_ASSOC);

        
// display
        
echo "<pre>";
        
print_r($rows);
        echo 
"</pre>";
    }
}
catch (
QueryPaginatorException $q)
{
    echo 
$q;    
}
catch (
Exception $e)
{
    echo 
$q->getMessage();
}

// close the database connection
@mysql_close($dbConnection);

?>