Login   Register  
PHP Classes
elePHPant
Icontem

File: create_table.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Mark Documento  >  Database Connection Classes  >  create_table.php  >  Download  
File: create_table.php
Role: Example script
Content type: text/plain
Description: Sample script 2
Class: Database Connection Classes
Abstract the access to SQL databases
Author: By
Last change:
Date: 2006-09-17 22:48
Size: 1,056 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);

    
$db->Begin();
    
$db->Execute("
        CREATE TABLE `person` (
            `id` int(10) unsigned NOT NULL auto_increment,
            `last_name` varchar(20) NOT NULL default '',
            `first_name` varchar(20) NOT NULL default '',
            `street_address` varchar(64) NOT NULL default '',
            `city` varchar(20) NOT NULL default '',
            `country` varchar(20) NOT NULL default '',
            `zip` varchar(5) NOT NULL default '',
            PRIMARY KEY(`id`),
            UNIQUE KEY `unique_name` (`last_name`,`first_name`)
        ) ENGINE=InnoDB"
);
    
$db->Commit();
    echo 
"Table test.person created.";
}
catch (
Exception $ex)
{
    
$db->Rollback();
    echo 
"Exception Caught: " $ex->getMessage() .
         
"<p>Trace: " $ex->getTraceAsString() . "</p>";
}

?>