- MySQLi 教程
- MySQLi - 首頁
- MySQLi - 介紹
- MySQLi - PHP 語法
- MySQLi - 連線
- MySQLi - 建立資料庫
- MySQLi - 刪除資料庫
- MySQLi - 選擇資料庫
- MySQLi - 建立表
- MySQLi - 刪除表
- MySQLi - 插入查詢
- MySQLi - 選擇查詢
- MySQLi - WHERE 子句
- MySQLi - 更新查詢
- MySQLi - 刪除查詢
- MySQLi - LIKE 子句
- MySQLi - 對結果排序
- MySQLi - 使用連線
- MySQLi - 處理 NULL 值
- 獲取和使用 MySQLi 元資料
- MySQL
- MySQL - 安裝
- MySQL - 管理
- MySQL - 資料型別
- MySQL - 正則表示式
- MySQL - 事務
- MySQL - ALTER 命令
- MySQL - 索引
- MySQL - 臨時表
- MySQL - 克隆表
- MySQL - 使用序列
- MySQL - 處理重複
- MySQLi 有用資源
- MySQLi - 有用函式
- MySQLi - 快速指南
- MySQLi - 有用資源
- MySQLi - 討論
MySQLi - 回滾
語法
bool mysqli_rollback ( mysqli $link [, int $flags [, string $name ]] )
定義和用法
它從當前事務的儲存點集合中移除指定的儲存點。
示例
嘗試以下示例 −
<?php
$servername = "localhost:3306";
$username = "root";
$password = "";
$dbname = "TUTORIALS";
$tmp = NULL;
$conn = new mysqli($servername, $username, $password, $dbname);
if (!$conn->real_connect($servername, $username, $password, $dbname)) {
die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
}
echo 'Success... ' . mysqli_get_host_info($conn) . "\n";
mysqli_query($conn, "CREATE TABLE tutorials_test1 LIKE tutorials_auto");
mysqli_query($conn, "ALTER TABLE tutorials_test1 Type = InnoDB");
mysqli_query($conn, "INSERT INTO tutorials_test1 SELECT * FROM id LIMIT 50");
mysqli_commit($conn);
mysqli_query($conn, "DELETE FROM tutorials_test1");
if ($result = mysqli_query($conn, "SELECT COUNT(*) FROM tutorials_test1")) {
$row = mysqli_fetch_row($result);
printf("%d rows in table tutorials_test1.\n", $row[0]);
mysqli_free_result($result);
}
mysqli_rollback($conn);
if ($result = mysqli_query($conn, "SELECT COUNT(*) FROM tutorials_test1")) {
$row = mysqli_fetch_row($result);
printf("%d rows in table tutorials_test1 (after rollback).\n", $row[0]);
mysqli_free_result($result);
}
mysqli_query($conn, "DROP TABLE tutorials_test1");
$conn->close();
?>
以上程式碼的示例輸出應如下所示 −
Success... localhost:3306 via TCP/IP 0 rows in table tutorials_test1. 0 rows in table tutorials_test1 (after rollback).
mysqli_useful_functions.htm
廣告