1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
--TEST--
mysqli autocommit/commit/rollback with innodb
--SKIPIF--
<?php
require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
require_once('connect.inc');
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
die(sprintf("Cannot connect, [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
if (!have_innodb($link))
die(sprintf("Needs InnoDB support, [%d] %s", $link->errno, $link->error));
?>
--FILE--
<?php
require_once("connect.inc");
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
if (!$link)
printf("[001] Cannot connect, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_select_db($link, $db))
printf("[002] Cannot select DB '%s', [%d] %s\n", $db,
mysqli_errno($link), mysqli_error($link));
if (!mysqli_autocommit($link, TRUE))
printf("[003] Cannot turn on autocommit mode, [%d] %s\n",
mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link,"DROP TABLE IF EXISTS test") ||
!mysqli_query($link,"CREATE TABLE test(a int, b varchar(10)) Engine=InnoDB") ||
!mysqli_query($link, "INSERT INTO test VALUES (1, 'foobar')"))
printf("[004] Cannot create test data, [%d] %s\n",
mysqli_errno($link), mysqli_error($link));
if (!mysqli_autocommit($link, FALSE))
printf("[005] Cannot turn off autocommit mode, [%d] %s\n",
mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, "DELETE FROM test") ||
!mysqli_query($link, "INSERT INTO test VALUES (2, 'egon')"))
printf("[006] Cannot modify test data, [%d] %s\n",
mysqli_errno($link), mysqli_error($link));
if (!mysqli_rollback($link))
printf("[007] Cannot call rollback, [%d] %s\n",
mysqli_errno($link), mysqli_error($link));
$result = mysqli_query($link, "SELECT SQL_NO_CACHE * FROM test");
if (!$result)
printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$row = mysqli_fetch_row($result);
mysqli_free_result($result);
var_dump($row);
if (!mysqli_query($link, "DELETE FROM test") ||
!mysqli_query($link, "INSERT INTO test VALUES (2, 'egon')"))
printf("[009] Cannot modify test data, [%d] %s\n",
mysqli_errno($link), mysqli_error($link));
mysqli_commit($link);
$result = mysqli_query($link, "SELECT * FROM test");
if (!$result)
printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$row = mysqli_fetch_row($result);
mysqli_free_result($result);
var_dump($row);
mysqli_query($link, "DROP TABLE IF EXISTS test");
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once("clean_table.inc");
?>
--EXPECTF--
array(2) {
[0]=>
string(1) "1"
[1]=>
string(6) "foobar"
}
array(2) {
[0]=>
string(1) "2"
[1]=>
string(4) "egon"
}
done!
|