summaryrefslogtreecommitdiff
path: root/ext/mysqli/tests/015.phpt
blob: f68e9aa72a45e6680df64418b7e6f1918aabd1b1 (plain)
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
--TEST--
mysqli autocommit/commit/rollback with innodb
--SKIPIF--
<?php
	require_once('skipif.inc');
	require_once('skipifconnectfailure.inc');
	include "connect.inc";
	$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
	$result = mysqli_query($link, "SHOW VARIABLES LIKE 'have_innodb'");
	$row = mysqli_fetch_row($result);
	mysqli_free_result($result);
	mysqli_close($link);

	if ($row[1] == "NO") {
		printf ("skip innodb support not installed.");
	}
?>
--FILE--
<?php
	include "connect.inc";

	$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);

	mysqli_select_db($link, $db);

	mysqli_autocommit($link, TRUE);

  	mysqli_query($link,"DROP TABLE IF EXISTS ac_01");

	mysqli_query($link,"CREATE TABLE ac_01(a int, b varchar(10)) Engine=InnoDB");

	mysqli_query($link, "INSERT INTO ac_01 VALUES (1, 'foobar')");
	mysqli_autocommit($link, FALSE);

	mysqli_query($link, "DELETE FROM ac_01");
	mysqli_query($link, "INSERT INTO ac_01 VALUES (2, 'egon')");

	mysqli_rollback($link);

	$result = mysqli_query($link, "SELECT SQL_NO_CACHE * FROM ac_01");
	$row = mysqli_fetch_row($result);
	mysqli_free_result($result);

	var_dump($row);

	mysqli_query($link, "DELETE FROM ac_01");
	mysqli_query($link, "INSERT INTO ac_01 VALUES (2, 'egon')");
	mysqli_commit($link);

	$result = mysqli_query($link, "SELECT * FROM ac_01");
	$row = mysqli_fetch_row($result);
	mysqli_free_result($result);

	var_dump($row);

	mysqli_close($link);
	print "done!";
?>
--EXPECTF--
array(2) {
  [0]=>
  string(1) "1"
  [1]=>
  string(6) "foobar"
}
array(2) {
  [0]=>
  string(1) "2"
  [1]=>
  string(4) "egon"
}
done!
--UEXPECTF--
array(2) {
  [0]=>
  unicode(1) "1"
  [1]=>
  unicode(6) "foobar"
}
array(2) {
  [0]=>
  unicode(1) "2"
  [1]=>
  unicode(4) "egon"
}
done!