PHP Classes

File: show_databases.php

Recommend this page to a friend!
  Classes of Mark Documento   Database Connection Classes   show_databases.php   Download  
File: show_databases.php
Role: Example script
Content type: text/plain
Description: Sample script 1
Class: Database Connection Classes
Abstract the access to SQL databases
Author: By
Last change:
Date: 17 years ago
Size: 636 bytes
 

Contents

Class file image Download
<?php

try
{
    include_once(
"connection.inc.php");
    include_once(
"mysql_database.inc.php");

   
$db = DBFactory::CreateDatabaseObject("MySqlDatabase");
   
$db->Connect($server, $database, $username, $password);

   
$dt = $db->Execute("SHOW DATABASES");
   
$content = "DATABASES:<br>";
    while (
$dt->MoveNext())
    {
       
$content .= "$dt->Database<br>";
       
// or use:
        //$content .= $dt->Field(0) . "<br>";
   
}
}
catch (
Exception $ex)
{
   
$content = "Exception Caught: " . $ex->getMessage() .
              
"<p>Trace: " . $ex->getTraceAsString() . "</p>";
}

echo
$content;

?>