<?php
// Instance a class. (access a class code to configure parameters).
require "class.mysqltransact.php";
// Define a database name
$dbname = "Example";
// Create a database
mysql_create_db($dbname) or die("Database not created.");
// Select a database
mysql_select_db("$dbname");
// Start transaction
$trans = new MySQL_Transact($id);
// Execute updates
$trans->AddSql("CREATE TABLE Accounts (AccountNumber VARCHAR(5) NOT NULL, AccountName VARCHAR(50) NOT NULL, AccountSold DOUBLE NULL, PRIMARY KEY(AccountNumber)) TYPE = InnoDB;");
$trans->AddSQL("INSERT INTO Accounts (AccountNumber, AccountName) VALUES ('00001', 'Sergio Fe'), ('00002', 'Nadja Marinho')");
$trans->AddSQL("UPDATE Accounts SET AccountSold = 1200 WHERE AccountNumber='00001'");
$trans->AddSQL("UPDATE Accounts SET AccountSold = 1600 WHERE AccountNumber='00002'");
// Commit or rollback transaction
if ($trans->Execute())
echo "Transaction success.";
else
echo "Transaction aborted.";
?>
<hr size="1" color="#ff9900">
End. <?= date("d/M/y h:m:s") ?>
|