Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Anderson Makiyama  >  PDO Paginator  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example
Class: PDO Paginator
Show links to browse query results got with PDO
Author: By
Last change:
Date: 2011-02-01 09:57
Size: 1,221 bytes
 

Contents

Class file image Download
<?php
//------------------------Data Base Connection
//Mysql Server
$servidor_mysql "localhost";

//User
$usuario_banco "root";

//Password
$senha_banco "";

//Database Name
$nome_banco "livrophp";

$_DATABASE = array('dbdriver' =>'mysql','dbhostname'=>$servidor_mysql,'dbusername'=>$usuario_banco,'dbpassword'=>$senha_banco,'dbname'=>$nome_banco);

$conn = new PDOPaginator($_DATABASE["dbdriver"].":host=".$_DATABASE["dbhostname"].";dbname=".$_DATABASE["dbname"],$_DATABASE["dbusername"],$_DATABASE["dbpassword"]);
$conn->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);


//------------------------Executing Queries

//Your Sql Here
$sql "select * from users";
$max_records_per_page 300;
$max_navigation_numbers 20;
$cache_session_name "my_session";

$conn->prepareLimit($sql,$max_records_per_page,$max_navigation_numbers,$cache_session_name);
$users $conn->execute();

while(
$line $users->fetch(PDO::FETCH_ASSOC);){
    echo 
$line["nm_user"];
}

//------------------------Showing the Paginator
//Normal Links
echo $conn->getLinks("default");

//Ajax Links
echo $conn->getLinks("ajax");

//Friendly Url Links
echo $conn->getLinks("friendlyUrl");
?>