1--TEST-- 2mysqli_rollback() 3--EXTENSIONS-- 4mysqli 5--SKIPIF-- 6<?php 7 require_once('skipifconnectfailure.inc'); 8 9 require_once('connect.inc'); 10 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 11 die(sprintf("skip Cannot connect, [%d] %s", mysqli_connect_errno(), mysqli_connect_error())); 12 13 if (!have_innodb($link)) 14 die(sprintf("skip Needs InnoDB support, [%d] %s", $link->errno, $link->error)); 15?> 16--FILE-- 17<?php 18 require_once("connect.inc"); 19 20 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 21 printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", 22 $host, $user, $db, $port, $socket); 23 24 if (true !== ($tmp = mysqli_autocommit($link, false))) 25 printf("[005] Cannot turn off autocommit, expecting true, got %s/%s\n", gettype($tmp), $tmp); 26 27 if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) 28 printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 29 30 if (!mysqli_query($link, 'CREATE TABLE test(id INT) ENGINE = InnoDB')) 31 printf("[007] Cannot create test table, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 32 33 if (!mysqli_query($link, 'INSERT INTO test(id) VALUES (1)')) 34 printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 35 36 $tmp = mysqli_rollback($link); 37 if ($tmp !== true) 38 printf("[009] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); 39 40 if (!$res = mysqli_query($link, 'SELECT COUNT(*) AS num FROM test')) 41 printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 42 $tmp = mysqli_fetch_assoc($res); 43 if (0 != $tmp['num']) 44 printf("[12] Expecting 0 rows in table test, found %d rows\n", $tmp['num']); 45 mysqli_free_result($res); 46 47 if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) 48 printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 49 50 mysqli_close($link); 51 52 try { 53 mysqli_rollback($link); 54 } catch (Error $exception) { 55 echo $exception->getMessage() . "\n"; 56 } 57 58 print "done!\n"; 59?> 60--CLEAN-- 61<?php 62 require_once("clean_table.inc"); 63?> 64--EXPECT-- 65mysqli object is already closed 66done! 67