mysqli_rollback
mysqli->rollback()
Rolls back current transaction
&reftitle.description;
boolmysqli_rollback
mysqlilink
mysqli
boolrollback
Rollbacks the current transaction for the database.
&reftitle.parameters;
&mysqli.link.description;
&reftitle.returnvalues;
&return.success;
&reftitle.examples;
Object oriented style
autocommit(FALSE);
$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->close();
?>
]]>
Procedural style
]]>
&example.outputs;
&reftitle.seealso;
mysqli_commit
mysqli_autocommit