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