Login   Register  
PHP Classes
elePHPant
Icontem

File: testcenter.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Björn Puttmann  >  OoMySql  >  testcenter.php  >  Download  
File: testcenter.php
Role: Example script
Content type: text/plain
Description: testfile - some demos
Class: OoMySql
OO MySQL interface with logging support
Author: By
Last change: switched debugging mode on by default
Date: 2003-06-17 15:26
Size: 1,596 bytes
 

Contents

Class file image Download
<?
// some examples....
require_once("init.inc.php");
// create a new sql object
$sql = new MySql("dbhost","dbuser","dbpass",true);
// get some info on mysql server
$server_info $sql->getServerInfo();
// create a database and receive databaseObj
$dbObject $sql->createDB('testDatabase');
// and get a list of databases
$result $sql->listDBs();
while (
$row mysql_fetch_row($result)) {
        print 
"Database: $row[0]<br>\n";
 }
print 
"------------------------------------------<br>\n";
// drop this newly created table
$dbObject->drop();
// and get a list of databases
$result $sql->listDBs();
while (
$row mysql_fetch_row($result)) {
        print 
"Database: $row[0]<br>\n";
 }
print 
"------------------------------------------<br>\n";
// select a database
$dbObject $sql->selectDB("anotherDB");
// and get a list of tables in this DB
$result $dbObject->listTables();
while (
$row mysql_fetch_row($result)) {
        print 
"Table in ".$dbObject->getName().": $row[0]<br>\n";
 }
 print 
"------------------------------------------<br>\n";
 
//    and create a table object linked to this DB table
 
$tableObj $dbObject->selectTable("someTable");
 
// turn debug messages for queries to this table on
 
$tableObj->debugtrue;
 
// insert a value
 
$result $tableObj->insert("someColumn","'someString'");
 
// get some meta infos
 
print "AffectedRows:".$tableObj->getAffectedRows()."<br>\n";
 
// get all data in this table
 
$result $tableObj->select("*");
 
// and print out number of hits
 
print "NumRows:".$tableObj->getNumRows()."<br>\n";
?>