<!DOCTYPE html><html><head></head><body>
<?php
$S=new mysqli("localhost","root","password","testDB");
$S->query("DROP TABLE IF EXISTS tbl");
$S->query("CREATE TABLE tbl (a INT)");
$S->begin_transaction();
$S->query("INSERT INTO tbl VALUES(100)");
$S->rollback();
$S->autocommit(FALSE);
$S->query("INSERT INTO tbl VALUES(200)");
$S->autocommit(TRUE);
tabulate($S->query("SELECT * FROM tbl"));
function tabulate($result){
$fInfo = $result->fetch_fields();
echo "<table border='1'><tr>";
foreach($fInfo as $col){
echo "<td>".$col->name."</td>";
}
while ($row = $result->fetch_row()){
echo "</tr><tr>";
foreach ($row as $val){
echo "<td>".$val."</td>";
}
}
echo "</tr></table><br/>";
}
?>
</body>
</html>
<!DOCTYPE html><html><head></head><body>
<?php
$S=new mysqli("localhost","root","password","testDB");
$S->query("DROP TABLE IF EXISTS tbl");
$S->query("CREATE TABLE tbl (a INT)");
$S->begin_transaction();
$S->query("INSERT INTO tbl VALUES(100)");
$S->rollback();
$S->autocommit(FALSE);
$S->query("INSERT INTO tbl VALUES(200)");
$S->autocommit(TRUE);
tabulate($S->query("SELECT * FROM tbl"));
function tabulate($result){
$fInfo = $result->fetch_fields();
echo "<table border='1'><tr>";
foreach($fInfo as $col){
echo "<td>".$col->name."</td>";
}
while ($row = $result->fetch_row()){
echo "</tr><tr>";
foreach ($row as $val){
echo "<td>".$val."</td>";
}
}
echo "</tr></table><br/>";
}
?>
</body>
</html>