PHP Classes

File: example1.PostgreSQL81.php

Recommend this page to a friend!
  Packages of Richard Munroe   dm.DB   example1.PostgreSQL81.php   Download  
File: example1.PostgreSQL81.php
Role: Example script
Content type: text/plain
Description: Example for PostgreSQL
Class: dm.DB
Generic database access wrapper
Author: By
Last change:
Date: 20 years ago
Size: 2,745 bytes
 

Contents

Class file image Download
<?php

/**
 * @author Dick Munroe <munroe@csworks.com>
 * @copyright copyright @ 2006 by Dick Munroe, Cottage Software Works, Inc.
 * @license http://www.csworks.com/publications/ModifiedNetBSD.html
 * @version 1.0.0
 * @package dm.DB
 * @example ./example.php
 */

require_once "class.DB.php";

header("content-type: text/html");

print "<html><head><title>HAHA</title></head><body>";

print "<h1>HELLO WORLD DB VERSION</h1><br>\n\n";

/*
 * Put the value of your database login name into this variable.
 */

$dblogin = "put your login name here" ;

/*
 * Put the value of your database login password into this variable.
 */

$dbpassword = "put your password here" ;

/*
 * Should you change the name of the database created by DB.sql, then
 * put the new name in the following variable.
 */

$dbdatabase = "DB" ;

$db = new DB($dblogin, $dbpassword, $dbdatabase);

$db->queryConstant("SELECT * FROM `table`");

print "<table bgcolor=\"#FFFFCC\" border=1><tr><th>id</th><th>title</th><th>price</th></tr>\n";

while( $db->fetchRow() )
{
    print "<tr><td>" . $db->record["id"] . "</td><td>" . 
      $db->record["fullname"] . "</td><td>" . 
      $db->record["user"] . "</td><td>" . 
      $db->record["password"] . "</td></tr>\n";
}

print "</table>\n\n";

print "<p>TESTING moveFirst()</p>\n";

if( $db->moveFirst() )
{
    print "FIRST REC: [" . $db->record["id"] . " || " . 
      $db->record["fullname"] . " || " . 
      $db->record["user"] . " || " . 
      $db->record["password"] . "]<br><br>\n";
}

print "<p>TESTING moveNext()</p>\n";

if( $db->moveNext() )
{
    print "NEXT REC: [" . $db->record["id"] . " || " . 
      $db->record["fullname"] . " || " . 
      $db->record["user"] . " || " . 
      $db->record["password"] . "]<br><br>\n";
}

print "<p>TESTING moveLast()</p>\n";

if( $db->moveLast() )
{
    print "LAST REC: [" . $db->record["id"] . " || " . 
      $db->record["fullname"] . " || " . 
      $db->record["user"] . " || " . 
      $db->record["password"] . "]<br><br>\n";
}


print "<p>TESTING movePrev()</p>\n";

if( $db->movePrev() )
{
    print "PREV REC: [" . $db->record["id"] . " || " . 
      $db->record["fullname"] . " || " . 
      $db->record["user"] . " || " . 
      $db->record["password"] . "]<br><br>\n";

}

// move to the last record and move backwords

$db->moveLast();

print "<p>BACKWORDS:</p>\n";

print "<table bgcolor=\"#FFFFCC\" border=1><tr><th>id</th><th>title</th><th>price</th></tr>\n";

while( $db->movePrev() )
{
    print "<tr><td>" . $db->record["id"] . "</td><td>" . 
      $db->record["fullname"] . "</td><td>" . 
      $db->record["user"] . "</td><td>" . 
      $db->record["password"] . "</td></tr>\n";
}

print "</table>\n\n";



// disconnect and show errors

$db->disconnect();
$db->showErrors();

print "</body></html>";

?>