Login   Register  
PHP Classes
elePHPant
Icontem

File: transaction.01.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.01.php  >  Download  
File: transaction.01.php
Role: Example script
Content type: text/plain
Description: Sample script 5
Class: Database Connection Classes
Abstract the access to SQL databases
Author: By
Last change:
Date: 8 years ago
Size: 1,074 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(
            'Documento',
            'Mark Jundo',
            'Visita St. Brgy. Sta. Cruz',
            'Makati City',
            'Philippines',
            '1205')"
);
    
$id $db->GetLastInsertID();
    
$db->Commit();
    
$dt $db->Execute("SELECT * FROM person WHERE id = $id");
    
$dt->MoveNext();
    echo 
"Inserted<br>
         
$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>";
}

?>