Login   Register  
PHP Classes
elePHPant
Icontem

File: transaction.02.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  >  transaction.02.php  >  Download  
File: transaction.02.php
Role: Example script
Content type: text/plain
Description: Sample script 6
Class: Database Connection Classes
Abstract the access to SQL databases
Author: By
Last change:
Date: 2006-09-17 22:50
Size: 1,070 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("
        INSERT INTO person(
            last_name,
            first_name,
            street_address,
            city,
            country,
            zip)
        VALUES(
            'Guinocor',
            'Joseph',
            'Diamond St. Doņa Luisa Village, Matina',
            'Davao City',
            -- Deliberate error: missing one field
            '8000')"
);
    
$id $db->GetLastInsertID();
    
$db->Commit();
    
$dt $db->Execute("SELECT * FROM person WHERE id = $id");
    
$dt->MoveNext();
    echo 
"$dt->last_name$dt->first_name<br>$dt->street_address$dt->city$dt->country $dt->zip";
}
catch (
Exception $ex)
{
    
$db->Rollback();
    echo 
"Exception Caught: " $ex->getMessage() .
         
"<p>Trace: " $ex->getTraceAsString() . "</p>";
}

?>