mysqli_rollback

(PHP 5 CVS only)

mysqli_rollback

(no version information, might be only in CVS)

mysqli->rollback -- Rolls back current transaction

Description

bool mysqli_rollback ( object link)

class mysqli {

bool rollback ( void )

}

Rollbacks the current transaction for the database specified by the link parameter.

Return values

Zwraca TRUE w przypadku sukcesu, FALSE w przypadku porażki.

See also

mysqli_commit() mysqli_autocommit()

Examples

Przykład 1. Object oriented style

<?php

$mysqli
= new mysqli("localhost", "my_user", "my_password", "test");

$mysqli->query("DROP TABLE IF EXISTS ta_sample");
$mysqli->query("CREATE TABLE ta_sample (a int) TYPE=InnoDB");

/* set autocommit to off */
$mysqli->autocommit(FALSE);

/* Insert some values */
$mysqli->query("INSERT INTO ta_sample VALUES (1)");
$mysqli->query("INSERT INTO ta_sample VALUES (1)");

/* rollback transaction */
$mysqli->rollback();

/* close connection */
$mysqli->close();
?>

Przykład 2. Procedural style

<?php

$link
= mysqli_connect("localhost", "my_user", "my_password", "test");

mysqli_query($link, "DROP TABLE IF EXISTS ta_sample");
mysqli_query($link, "CREATE TABLE ta_sample (a int) TYPE=InnoDB");

/* set autocommit to off */
mysqli_autocommit($link, FALSE);

/* Insert some values */
mysqli_query($link, "INSERT INTO ta_sample VALUES (1)");
mysqli_query($link, "INSERT INTO ta_sample VALUES (1)");

/* rollback transaction */
mysqli_rollback($link);

/* close connection */
mysqli_close($link);
?>