<?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>";
}
?>
|