<?php require_once('skipif.inc'); ?>
--FILE--
<?php
- include "connect.inc";
-
- $tmp = NULL;
- $link = NULL;
-
- if (false !== ($tmp = @mysql_affected_rows()))
- printf("[001] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
-
- if (false !== ($tmp = @mysql_affected_rows($link)))
- printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
-
- if (!is_null($tmp = @mysql_affected_rows($link, $link)))
- printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
-
- if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket))
- printf("[004] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
- $host, $user, $db, $port, $socket);
-
- if (-1 !== ($tmp = mysql_affected_rows($link)))
- printf("[005] Expecting int/-1, got %s/%s. [%d] %s\n",
- gettype($tmp), $tmp, mysql_errno($link), mysql_error($link));
-
- if (!mysql_query('DROP TABLE IF EXISTS test', $link))
- printf("[006] [%d] %s\n", mysql_errno($link), mysql_error($link));
-
- if (!mysql_query('CREATE TABLE test(id INT, label CHAR(1), PRIMARY KEY(id)) ENGINE = ' . $engine, $link))
- printf("[007] [%d] %s\n", mysql_errno($link), mysql_error($link));
-
- if (!mysql_query('INSERT INTO test(id, label) VALUES (1, "a")', $link))
- printf("[008] [%d] %s\n", mysql_errno($link), mysql_error($link));
-
- if (1 !== ($tmp = mysql_affected_rows($link)))
- printf("[010] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp);
-
- // ignore INSERT error, NOTE: command line returns 0, affected_rows returns -1 as documented
- mysql_query('INSERT INTO test(id, label) VALUES (1, "a")', $link);
- if (-1 !== ($tmp = mysql_affected_rows($link)))
- printf("[011] Expecting int/-1, got %s/%s\n", gettype($tmp), $tmp);
-
- if (!mysql_query('INSERT INTO test(id, label) VALUES (1, "a") ON DUPLICATE KEY UPDATE id = 4', $link))
- printf("[012] [%d] %s\n", mysql_errno($link), mysql_error($link));
-
- if (2 !== ($tmp = mysql_affected_rows($link)))
- printf("[013] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp);
-
- if (!mysql_query("INSERT INTO test(id, label) VALUES (2, 'b'), (3, 'c')", $link))
- printf("[014] [%d] %s\n", mysql_errno($link), mysql_error($link));
-
- if (2 !== ($tmp = mysql_affected_rows($link)))
- printf("[015] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp);
-
- if (!mysql_query("INSERT IGNORE INTO test(id, label) VALUES (1, 'a')", $link)) {
- printf("[016] [%d] %s\n", mysql_errno($link), mysql_error($link));
- }
-
- if (1 !== ($tmp = mysql_affected_rows($link)))
- printf("[017] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp);
-
- if (!mysql_query("INSERT INTO test(id, label) SELECT id + 10, label FROM test", $link))
- printf("[018] [%d] %s\n", mysql_errno($link), mysql_error($link));
-
- if (4 !== ($tmp = mysql_affected_rows($link)))
- printf("[019] Expecting int/4, got %s/%s\n", gettype($tmp), $tmp);
-
- if (!mysql_query("REPLACE INTO test(id, label) values (4, 'd')", $link))
- printf("[020] [%d] %s\n", mysql_errno($link), mysql_error($link));
-
- if (2 !== ($tmp = mysql_affected_rows($link)))
- printf("[021] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp);
-
- if (!mysql_query("REPLACE INTO test(id, label) values (5, 'e')", $link))
- printf("[022] [%d] %s\n", mysql_errno($link), mysql_error($link));
-
- if (1 !== ($tmp = mysql_affected_rows($link)))
- printf("[023] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp);
-
- if (!mysql_query("UPDATE test SET label = 'a' WHERE id = 2", $link))
- printf("[024] [%d] %s\n", mysql_errno($link), mysql_error($link));
-
- if (1 !== ($tmp = mysql_affected_rows($link)))
- printf("[025] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp);
-
- if (!mysql_query("UPDATE test SET label = 'a' WHERE id = 2", $link)) {
- printf("[025] [%d] %s\n", mysql_errno($link), mysql_error($link));
- }
-
- if (0 !== ($tmp = mysql_affected_rows($link)))
- printf("[026] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp);
-
- if (!mysql_query("UPDATE test SET label = 'a' WHERE id = 100", $link)) {
- printf("[025] [%d] %s\n", mysql_errno($link), mysql_error($link));
- }
-
- if (0 !== ($tmp = mysql_affected_rows($link)))
- printf("[026] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp);
-
- if (!mysql_query('DROP TABLE IF EXISTS test', $link))
- printf("[027] [%d] %s\n", mysql_errno($link), mysql_error($link));
-
- mysql_close($link);
-
- if (false !== ($tmp = @mysql_affected_rows($link)))
- printf("[028] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
-
- print "done!";
+include_once("connect.inc");
+
+$tmp = NULL;
+$link = NULL;
+
+if (false !== ($tmp = @mysql_affected_rows()))
+ printf("[001] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
+
+if (false !== ($tmp = @mysql_affected_rows($link)))
+ printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
+
+if (!is_null($tmp = @mysql_affected_rows($link, $link)))
+ printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
+
+if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket))
+ printf("[004] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket);
+
+if (-1 !== ($tmp = mysql_affected_rows($link)))
+ printf("[005] Expecting int/-1, got %s/%s. [%d] %s\n",
+ gettype($tmp), $tmp, mysql_errno($link), mysql_error($link));
+
+if (!mysql_query('DROP TABLE IF EXISTS test', $link))
+ printf("[006] [%d] %s\n", mysql_errno($link), mysql_error($link));
+
+if (!mysql_query('CREATE TABLE test(id INT, label CHAR(1), PRIMARY KEY(id)) ENGINE = ' . $engine, $link))
+ printf("[007] [%d] %s\n", mysql_errno($link), mysql_error($link));
+
+if (!mysql_query('INSERT INTO test(id, label) VALUES (1, "a")', $link))
+ printf("[008] [%d] %s\n", mysql_errno($link), mysql_error($link));
+
+if (1 !== ($tmp = mysql_affected_rows($link)))
+ printf("[010] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp);
+
+// ignore INSERT error, NOTE: command line returns 0, affected_rows returns -1 as documented
+@mysql_query('INSERT INTO test(id, label) VALUES (1, "a")', $link);
+if (-1 !== ($tmp = mysql_affected_rows($link)))
+ printf("[011] Expecting int/-1, got %s/%s\n", gettype($tmp), $tmp);
+
+if (!mysql_query('INSERT INTO test(id, label) VALUES (1, "a") ON DUPLICATE KEY UPDATE id = 4', $link))
+ printf("[012] [%d] %s\n", mysql_errno($link), mysql_error($link));
+
+if (2 !== ($tmp = mysql_affected_rows($link)))
+ printf("[013] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp);
+
+if (!mysql_query("INSERT INTO test(id, label) VALUES (2, 'b'), (3, 'c')", $link))
+ printf("[014] [%d] %s\n", mysql_errno($link), mysql_error($link));
+
+if (2 !== ($tmp = mysql_affected_rows($link)))
+ printf("[015] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp);
+
+if (!mysql_query("INSERT IGNORE INTO test(id, label) VALUES (1, 'a')", $link)) {
+ printf("[016] [%d] %s\n", mysql_errno($link), mysql_error($link));
+}
+
+if (1 !== ($tmp = mysql_affected_rows($link)))
+ printf("[017] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp);
+
+if (!mysql_query("INSERT INTO test(id, label) SELECT id + 10, label FROM test", $link))
+ printf("[018] [%d] %s\n", mysql_errno($link), mysql_error($link));
+
+if (4 !== ($tmp = mysql_affected_rows($link)))
+ printf("[019] Expecting int/4, got %s/%s\n", gettype($tmp), $tmp);
+
+if (!mysql_query("REPLACE INTO test(id, label) values (4, 'd')", $link))
+ printf("[020] [%d] %s\n", mysql_errno($link), mysql_error($link));
+
+if (2 !== ($tmp = mysql_affected_rows($link)))
+ printf("[021] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp);
+
+if (!mysql_query("REPLACE INTO test(id, label) values (5, 'e')", $link))
+ printf("[022] [%d] %s\n", mysql_errno($link), mysql_error($link));
+
+if (1 !== ($tmp = mysql_affected_rows($link)))
+ printf("[023] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp);
+
+if (!mysql_query("UPDATE test SET label = 'a' WHERE id = 2", $link))
+ printf("[024] [%d] %s\n", mysql_errno($link), mysql_error($link));
+
+if (1 !== ($tmp = mysql_affected_rows($link)))
+ printf("[025] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp);
+
+if (!mysql_query("UPDATE test SET label = 'a' WHERE id = 2", $link)) {
+ printf("[025] [%d] %s\n", mysql_errno($link), mysql_error($link));
+}
+
+if (0 !== ($tmp = mysql_affected_rows($link)))
+ printf("[026] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp);
+
+if (!mysql_query("UPDATE test SET label = 'a' WHERE id = 100", $link)) {
+ printf("[025] [%d] %s\n", mysql_errno($link), mysql_error($link));
+}
+
+if (0 !== ($tmp = mysql_affected_rows($link)))
+ printf("[026] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp);
+
+if (0 !== ($tmp = mysql_affected_rows()))
+ printf("[027] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp);
+
+if (!mysql_query('DROP TABLE IF EXISTS test', $link))
+ printf("[028] [%d] %s\n", mysql_errno($link), mysql_error($link));
+
+mysql_close($link);
+
+if (false !== ($tmp = @mysql_affected_rows($link)))
+ printf("[029] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
+
+print "done!";
?>
--EXPECTF--
-done!
+done!
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
- include_once "connect.inc";
-
- $tmp = NULL;
- $link = NULL;
-
- if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket))
- printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
- $host, $user, $db, $port, $socket);
-
- $default_link_enc = mysql_client_encoding();
- $link_enc = mysql_client_encoding($link);
-
- if ($default_link_enc !== $link_enc)
- printf("[003] %s != %s, [%d] %s\n", $default_link_enc, $link_enc, mysql_errno($link), mysql_error($link));
-
- if (!$res = mysql_query('SELECT version() AS server_version', $link))
- printf("[004] [%d] %s\n", mysql_errno($link), mysql_error($link));
- $tmp = mysql_fetch_assoc($res);
- mysql_free_result($res);
- $version = explode('.', $tmp['server_version']);
- if (empty($version))
- printf("[005] Cannot determine server version, need MySQL Server 4.1+ for the test!\n");
+include_once "connect.inc";
- if ($version[0] <= 4 && $version[1] < 1)
- printf("[006] Need MySQL Server 4.1+ for the test!\n");
+$tmp = NULL;
+$link = NULL;
- if (!$res = mysql_query('SELECT @@character_set_connection AS charset, @@collation_connection AS collation', $link))
- printf("[007] [%d] %s\n", mysql_errno($link), mysql_error($link));
- $tmp = mysql_fetch_assoc($res);
- mysql_free_result($res);
- if (!$tmp['charset'])
- printf("[008] Cannot determine current character set and collation\n");
-
- if ($link_enc !== $tmp['charset']) {
- if ($link_enc === $tmp['collation']) {
- printf("[009] Known bug, collation instead of chatset returned, http://bugs.mysql.com/bug.php?id=7923\n");
- } else {
- printf("[009] Check manually, watch out for unicode and others\n");
- var_dump($link_enc);
- var_dump($tmp);
- }
- }
+if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket))
+ printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket);
- if (ini_get('unicode.semantics') && function_exists('is_unicode')) {
- // unicode mode
- if (!is_unicode($default_link_enc) || !is_unicode($link_enc)) {
- printf("[010] No unicode returned!\n");
- var_dump($default_link_enc);
- var_dump($link_enc);
- }
+$default_link_enc = mysql_client_encoding();
+$link_enc = mysql_client_encoding($link);
- }
-
- mysql_close($link);
-
- if (false !== ($tmp = @mysql_client_encoding($link)))
- printf("[012] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
-
- print "done!";
+if ($default_link_enc !== $link_enc)
+ printf("[003] %s != %s, [%d] %s\n", $default_link_enc, $link_enc, mysql_errno($link), mysql_error($link));
+
+if (!$res = mysql_query('SELECT version() AS server_version', $link))
+ printf("[004] [%d] %s\n", mysql_errno($link), mysql_error($link));
+$tmp = mysql_fetch_assoc($res);
+mysql_free_result($res);
+$version = explode('.', $tmp['server_version']);
+if (empty($version))
+ printf("[005] Cannot determine server version, need MySQL Server 4.1+ for the test!\n");
+
+if ($version[0] <= 4 && $version[1] < 1)
+ printf("[006] Need MySQL Server 4.1+ for the test!\n");
+
+if (!$res = mysql_query('SELECT @@character_set_connection AS charset, @@collation_connection AS collation', $link))
+ printf("[007] [%d] %s\n", mysql_errno($link), mysql_error($link));
+$tmp = mysql_fetch_assoc($res);
+mysql_free_result($res);
+if (!$tmp['charset'])
+ printf("[008] Cannot determine current character set and collation\n");
+
+if ($link_enc !== $tmp['charset']) {
+ if ($link_enc === $tmp['collation']) {
+ printf("[009] Known bug, collation instead of chatset returned, http://bugs.mysql.com/bug.php?id=7923\n");
+ } else {
+ printf("[009] Check manually, watch out for unicode and others\n");
+ var_dump($link_enc);
+ var_dump($tmp);
+ }
+}
+
+if (ini_get('unicode.semantics') && function_exists('is_unicode')) {
+// unicode mode
+ if (!is_unicode($default_link_enc) || !is_unicode($link_enc)) {
+ printf("[010] No unicode returned!\n");
+ var_dump($default_link_enc);
+ var_dump($link_enc);
+ }
+}
+
+mysql_close($link);
+
+if (false !== ($tmp = @mysql_client_encoding($link)))
+ printf("[012] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
+
+print "done!";
?>
--EXPECTF--
done!
mysql_close()
--SKIPIF--
<?php require_once('skipif.inc'); ?>
-<?php require_once('skipifemb.inc'); ?>
--FILE--
<?php
- include "connect.inc";
-
- $db = 'test';
- $tmp = NULL;
- $link = NULL;
-
- if (false !== ($tmp = @mysql_close()))
- printf("[001] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
-
- if (NULL !== ($tmp = @mysql_close($link, $link)))
- printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
-
- if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket))
- printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
- $host, $user, $db, $port, $socket);
-
- $tmp = @mysql_close(NULL);
- if (false !== $tmp)
- printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
-
- $tmp = mysql_close($link);
- if (true !== $tmp)
- printf("[005] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
-
- if (false !== ($tmp = @mysql_query("SELECT 1", $link)))
- printf("[006] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
-
- print "done!\n";
-
+include "connect.inc";
+
+$tmp = NULL;
+$link = NULL;
+
+if (false !== ($tmp = @mysql_close()))
+ printf("[001] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
+
+if (NULL !== ($tmp = @mysql_close($link, $link)))
+ printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
+
+if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket))
+ printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket);
+
+$tmp = @mysql_close(NULL);
+if (false !== $tmp)
+ printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
+
+$tmp = mysql_close($link);
+if (true !== $tmp)
+ printf("[005] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
+
+if (false !== ($tmp = @mysql_query("SELECT 1", $link)))
+ printf("[006] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
+
+print "done!\n";
?>
--EXPECTF--
done!
\ No newline at end of file