php-src/ext/mysqli/tests/015.phpt
Ulf Wendel 1855a57471 Introducing new environment variable:
MYSQL_TEST_SKIP_CONNECT_FAILURE = false

Every test that needs a working MySQL connection now includes
skipifconnectfailure.inc. If MYSQL_TEST_SKIP_CONNECT_FAILURE evaluates
to true skipifconnectfailure.inc tries to establish a database
connection. If no connection can be opened, the test will be skipped.
In case of MYSQL_TEST_SKIP_CONNECT_FAILURE = false (default) an no
connection, a test who cannot establish a connection will fail.

So, if you have a buggy configuration or a server that is sometimes
not available, you can now decide if you want the tests to ignore this
and skip the test or to fail (MYSQL_TEST_CONNECT_FAILURE = false, default).

Other, minor tweaks:
  042.phpt - whitespace
  067.phpt - parse error in SKIPIF section fixed
2007-08-09 08:41:12 +00:00

86 lines
1.7 KiB
PHP

--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!