PHP Classes

File: example.php

Recommend this page to a friend!
  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: 11 years ago
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");
?>

For more information send a message to info at phpclasses dot org.