$mysqli->query("CREATE TABLE myCity LIKE City"); $mysqli->query("ALTER TABLE myCity Type=InnoDB"); $mysqli->query("INSERT INTO myCity SELECT * FROM City LIMIT 50");
/* commit insert */ $mysqli->commit();
/* delete all rows */ $mysqli->query("DELETE FROM myCity");
if ($result = $mysqli->query("SELECT COUNT(*) FROM myCity")) { $row = $result->fetch_row(); printf("%d rows in table myCity.\n", $row[0]); /* Free result */ $result->close(); }
/* Rollback */ $mysqli->rollback();
if ($result = $mysqli->query("SELECT COUNT(*) FROM myCity")) { $row = $result->fetch_row(); printf("%d rows in table myCity (after rollback).\n", $row[0]); /* Free result */ $result->close(); }
/* Drop table myCity */ $mysqli->query("DROP TABLE myCity");
mysqli_query($link, "CREATE TABLE myCity LIKE City"); mysqli_query($link, "ALTER TABLE myCity Type=InnoDB"); mysqli_query($link, "INSERT INTO myCity SELECT * FROM City LIMIT 50");
/* commit insert */ mysqli_commit($link);
/* delete all rows */ mysqli_query($link, "DELETE FROM myCity");
if ($result = mysqli_query($link, "SELECT COUNT(*) FROM myCity")) { $row = mysqli_fetch_row($result); printf("%d rows in table myCity.\n", $row[0]); /* Free result */ mysqli_free_result($result); }
/* Rollback */ mysqli_rollback($link);
if ($result = mysqli_query($link, "SELECT COUNT(*) FROM myCity")) { $row = mysqli_fetch_row($result); printf("%d rows in table myCity (after rollback).\n", $row[0]); /* Free result */ mysqli_free_result($result); }
/* Drop table myCity */ mysqli_query($link, "DROP TABLE myCity");
mysqli_close($link); ?>
The above example will output:
0 rows in table myCity.
50 rows in table myCity (after rollback).
Php mysqli rollback Function syntax tag
mysqli rollback php code on this is provided for your study purpose, it will guide you to know how create and design a website using php. use it to practice and train your self online
Php mysqli rollback syntax tutorial
php tutorial guide and code design are for easy learning and programming. The code practice section provided at the top is for practising of this syntax. Use the code section up to practice your php programming online. Learning php is very easy, all you need is to use the examples on this site and practice them to perfect your skills.