<?php require_once "connect.inc"; $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket); $mysql->query("CREATE TABLE temp (id INT UNSIGNED NOT NULL)"); $mysql->query("INSERT INTO temp (id) VALUES (3000000897),(3800001532),(3900002281),(3100059612)"); $stmt = $mysql->prepare("SELECT id FROM temp"); $stmt->execute(); $stmt->bind_result($id); while ($stmt->fetch()) { if (PHP_INT_SIZE == 8) { if (gettype($id) !== 'int' && gettype($id) != 'integer') { printf("[001] Expecting integer on 64bit got %s/%s\n", gettype($id), var_export($id, true)); } } else { if (gettype($id) !== 'string') { printf("[002] Expecting string on 32bit got %s/%s\n", gettype($id), var_export($id, true)); } if (version_compare(PHP_VERSION, '6.0', '==') == 1 && !is_unicode($id)) { printf("[003] Expecting unicode string\n"); } } print $id; print "\n"; } $stmt->close(); $mysql->query("DROP TABLE temp"); $mysql->close(); print "done!";
$mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket); $mysql->query("CREATE TABLE test_bug35517_table_1 (id INT UNSIGNED NOT NULL)"); $mysql->query("INSERT INTO test_bug35517_table_1 (id) VALUES (3000000897),(3800001532),(3900002281),(3100059612)"); $stmt = $mysql->prepare("SELECT id FROM test_bug35517_table_1"); $stmt->execute(); $stmt->bind_result($id); while ($stmt->fetch()) { if (PHP_INT_SIZE == 8) { if (gettype($id) !== 'int' && gettype($id) != 'integer') { printf("[001] Expecting integer on 64bit got %s/%s\n", gettype($id), var_export($id, true)); } } else { if (gettype($id) !== 'string') { printf("[002] Expecting string on 32bit got %s/%s\n", gettype($id), var_export($id, true)); } if (version_compare(PHP_VERSION, '5.9.9', '>') == 1 && !is_unicode($id)) { printf("[003] Expecting unicode string\n"); } } print $id; print "\n"; } $stmt->close(); $mysql->query("DROP TABLE test_bug35517_table_1"); $mysql->close(); print "done!"; require_once "connect.inc"; if (!($link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))) { printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); } if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bug35517_table_1")) {
<?php require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'; $db = MySQLPDOTest::factory(); $status = $db->getAttribute(PDO::ATTR_CONNECTION_STATUS); if (ini_get('unicode.semantics')) { if (!is_unicode($status)) { printf("[001] Expecting unicode, got '%s'\n", var_export($status, true)); } } else { if (!is_string($status)) { printf("[002] Expecting string, got '%s'\n", var_export($status, true)); } } if ('' == $status) { printf("[003] Connection status string must not be empty\n"); } if (false !== $db->setAttribute(PDO::ATTR_CONNECTION_STATUS, 'my own connection status')) { printf("[004] Changing read only attribute\n"); } $status2 = $db->getAttribute(PDO::ATTR_CONNECTION_STATUS); if ($status !== $status2) { printf("[005] Connection status should not have changed\n"); } print "done!";
printf("[003] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); } require 'table.inc'; if (!($res = @mysql_db_query($db, 'SELECT id, label FROM test ORDER BY id LIMIT 1', $link))) { printf("[004] [%d] %s\n", mysql_errno($link), mysql_error($link)); } $row = mysql_fetch_assoc($res); if (1 != $row['id']) { printf("[005] Expecting record 1/a, got record %s/%s\n", $row['id'], $row['label']); } if (version_compare(PHP_VERSION, '5.9.9', '>') == 1 && !is_unicode($row['label'])) { printf("[006] No unicode returned! [%d] %s\n", mysql_errno($link), mysql_error($link)); var_inspect($row); } mysql_free_result($res); if (!($res = @mysql_db_query($db, 'SELECT id, label FROM test ORDER BY id LIMIT 1'))) { printf("[007] [%d] %s\n", mysql_errno(), mysql_error()); } $row = mysql_fetch_assoc($res); if (1 != $row['id']) { printf("[008] Expecting record 1/a, got record %s/%s\n", $row['id'], $row['label']); } if (version_compare(PHP_VERSION, '5.9.9', '>') == 1 && !is_unicode($row['label'])) { printf("[009] No unicode returned! [%d] %s\n", mysql_errno(), mysql_error()); var_inspect($row); } mysql_free_result($res); mysql_close($link); print "done!\n"; error_reporting(0); require_once "clean_table.inc";
printf("[010] Expecting unicode string, dumping\n"); var_dump($tmp); } mysql_free_result($res); } else { printf("[011] [%d] %s\n", mysql_errno($link), mysql_error($link)); } mysql_query('DROP FUNCTION IF EXISTS f', $link); if (mysql_query('CREATE FUNCTION f( ver_param VARCHAR(25)) RETURNS VARCHAR(25) DETERMINISTIC RETURN ver_param;', $link)) { $res = mysql_query('SELECT f(VERSION()) AS f_version', $link); $tmp = mysql_fetch_assoc($res); if (!isset($tmp['f_version']) || '' == $tmp['f_version']) { printf("[012] Result seems wrong, dumping\n"); var_dump($tmp); } if (version_compare(PHP_VERSION, '5.9.9', '>') == 1 && !is_unicode($tmp['f_version'])) { printf("[013] Expecting unicode string, dumping\n"); var_dump($tmp); } mysql_free_result($res); } else { printf("[014] [%d] %s\n", mysql_errno($link), mysql_error($link)); } } mysql_close($link); if (false !== ($tmp = mysql_query("SELECT id FROM test", $link))) { printf("[011] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); } print "done!"; require_once 'connect.inc'; // connect + select_db
} 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 (version_compare(PHP_VERSION, '5.9.9', '>') == 1 && 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!";
printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); } require 'table.inc'; if (!($res = @mysql_list_dbs($link))) { printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link)); } if (!($num = mysql_num_rows($res))) { printf("[004] Empty database list? [%d] %s\n", mysql_errno($link), mysql_error($link)); } if (false !== ($tmp = mysql_db_name($res, -1))) { printf("[005] Expecting boolean/false, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysql_errno($link), mysql_error($link)); } if (false !== ($tmp = mysql_db_name($res, $num + 1))) { printf("[006] Expecting boolean/false, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysql_errno($link), mysql_error($link)); } $unicode = (bool) (version_compare(PHP_VERSION, '5.9.9', '>') == 1); for ($i = 0; $i < $num; $i++) { if ('' === ($dbname = mysql_db_name($res, $i))) { printf("[%03d] Got empty database name! [%d] %s\n", $i * 2 + 1 + 6, mysql_errno($link), mysql_error($link)); } if ($unicode && !is_unicode($dbname)) { printf("[%03d] Expecting unicode string! [%d] %s\n", $i * 2 + 2 + 6, mysql_errno($link), mysql_error($link)); var_inspect($dbname); } } mysql_free_result($res); if (false !== ($tmp = mysql_db_name($res, $num))) { printf("[999] Expecting boolean/false, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysql_errno($link), mysql_error($link)); } mysql_close($link); print "done!\n";