mysqli_rollback
mysqli->rollback
Rolls back current transaction
Description
boolmysqli_rollback
mysqlilink
mysqli
boolrollback
Rollbacks the current transaction for the database specified by the
link parameter.
&reftitle.returnvalues;
&return.success;
&reftitle.seealso;
mysqli_commit&listendand;
mysqli_autocommit.
&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;