cvs: php-src /ext/mysqli/tests mysqli_autocommit.phpt mysqli_autocommit_oo.phpt mysqli_change_user.phpt mysqli_change_user_oo.phpt
mysqli_character_set.phpt mysqli_character_set_name.phpt mysqli_character_set_name_oo.phpt mysqli_close.phpt mysqli_close_oo.phpt mysqli_commit.phpt
mysqli_commit_oo.phpt mysqli_constants.phpt mysqli_constants_categories.phpt mysqli_data_seek.phpt mysqli_data_seek_oo.phpt mysqli_debug.phpt
mysqli_disable_reads_from_master.phpt mysqli_disable_rpl_parse.phpt mysqli_driver.phpt mysqli_dump_debug_info.phpt mysqli_dump_debug_info_oo.phpt
mysqli_embedded_connect.phpt mysqli_enable_reads_from_master.phpt mysqli_enable_rpl_parse.phpt mysqli_errno.phpt mysqli_errno_oo.phpt
mysqli_error.phpt mysqli_error_oo.phpt mysqli_error_unicode.phpt mysqli_explain_metadata.phpt mysqli_fetch_lengths.phpt mysqli_fetch_lengths_oo.phpt
mysqli_field_count.phpt mysqli_field_seek.phpt mysqli_field_tell.phpt mysqli_free_result.phpt mysqli_get_charset.phpt mysqli_get_! client_info.phpt
mysqli_get_client_version.phpt mysqli_get_connection_stats.phpt mysqli_get_host_info.phpt mysqli_get_proto_info.phpt mysqli_get_server_info.phpt
mysqli_get_server_version.phpt mysqli_get_warnings.phpt mysqli_info.phpt mysqli_init.phpt mysqli_insert_id.phpt mysqli_kill.phpt
mysqli_more_results.phpt mysqli_multi_query.phpt mysqli_mysqli_result_invalid_mode.phpt mysqli_next_result.phpt mysqli_num_fields.phpt
mysqli_num_rows.phpt mysqli_options.phpt mysqli_options_init_command.phpt mysqli_pconnect.phpt mysqli_phpinfo.phpt mysqli_ping.phpt
mysqli_prepare.phpt mysqli_prepare_no_object.phpt mysqli_query.phpt mysqli_query_unicode.phpt mysqli_real_escape_string.phpt
mysqli_real_escape_string_unicode.phpt mysqli_real_query.phpt mysqli_report.phpt mysqli_report_wo_ps.phpt mysqli_result_references.phpt
mysqli_result_references_mysqlnd.phpt mysqli_rollback.phpt mysqli_select_db.phpt mysqli_set_charset.phpt mysqli_set_opt.phpt
mysqli_set_opt_numeric_and_datetime_as_unico! de.phpt mysqli_sqlstate.phpt mysqli_ssl_set.phpt mysqli_stat.phpt mysqli_stmt_affected_rows.phpt
mysqli_stmt_attr_get.phpt mysqli_stmt_attr_get_prefetch.phpt mysqli_stmt_attr_set.phpt mysqli_stmt_bind_param.phpt
mysqli_stmt_bind_param_references.phpt mysqli_stmt_bind_param_type_juggling.phpt mysqli_stmt_bind_result.phpt mysq
| From: | Ulf Wendel | Date: | Mon, 23 Jul 2007 12:38:41 +0000 |
| Subject: | cvs: php-src /ext/mysqli/tests mysqli_autocommit.phpt mysqli_autocommit_oo.phpt mysqli_change_user.phpt mysqli_change_user_oo.phpt mysqli_character_set.phpt mysqli_character_set_name.phpt mysqli_character_set_name_oo.phpt mysqli_close.phpt mysqli_close_oo.phpt mysqli_commit.phpt mysqli_commit_oo.phpt mysqli_constants.phpt mysqli_constants_categories.phpt mysqli_data_seek.phpt mysqli_data_seek_oo.phpt mysqli_debug.phpt mysqli_disable_reads_from_master.phpt mysqli_disable_rpl_parse.phpt mysqli_driver.phpt mysqli_dump_debug_info.phpt mysqli_dump_debug_info_oo.phpt mysqli_embedded_connect.phpt mysqli_enable_reads_from_master.phpt mysqli_enable_rpl_parse.phpt mysqli_errno.phpt mysqli_errno_oo.phpt mysqli_error.phpt mysqli_error_oo.phpt mysqli_error_unicode.phpt mysqli_explain_metadata.phpt mysqli_fetch_lengths.phpt mysqli_fetch_lengths_oo.phpt mysqli_field_count.phpt mysqli_field_seek.phpt mysqli_field_tell.phpt mysqli_free_result.phpt mysqli_get_charset.phpt mysqli_get_! client_info.phpt mysqli_get_client_version.phpt mysqli_get_connection_stats.phpt mysqli_get_host_info.phpt mysqli_get_proto_info.phpt mysqli_get_server_info.phpt mysqli_get_server_version.phpt mysqli_get_warnings.phpt mysqli_info.phpt mysqli_init.phpt mysqli_insert_id.phpt mysqli_kill.phpt mysqli_more_results.phpt mysqli_multi_query.phpt mysqli_mysqli_result_invalid_mode.phpt mysqli_next_result.phpt mysqli_num_fields.phpt mysqli_num_rows.phpt mysqli_options.phpt mysqli_options_init_command.phpt mysqli_pconnect.phpt mysqli_phpinfo.phpt mysqli_ping.phpt mysqli_prepare.phpt mysqli_prepare_no_object.phpt mysqli_query.phpt mysqli_query_unicode.phpt mysqli_real_escape_string.phpt mysqli_real_escape_string_unicode.phpt mysqli_real_query.phpt mysqli_report.phpt mysqli_report_wo_ps.phpt mysqli_result_references.phpt mysqli_result_references_mysqlnd.phpt mysqli_rollback.phpt mysqli_select_db.phpt mysqli_set_charset.phpt mysqli_set_opt.phpt mysqli_set_opt_numeric_and_datetime_as_unico! de.phpt mysqli_sqlstate.phpt mysqli_ssl_set.phpt mysqli_stat.phpt mysqli_stmt_affected_rows.phpt mysqli_stmt_attr_get.phpt mysqli_stmt_attr_get_prefetch.phpt mysqli_stmt_attr_set.phpt mysqli_stmt_bind_param.phpt mysqli_stmt_bind_param_references.phpt mysqli_stmt_bind_param_type_juggling.phpt mysqli_stmt_bind_result.phpt mysq |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-45548@lists.php.net to get a copy of this message | ||
uw Mon Jul 23 12:38:41 2007 UTC
Added files:
/php-src/ext/mysqli/tests mysqli_change_user.phpt
mysqli_change_user_oo.phpt
mysqli_character_set.phpt
mysqli_character_set_name.phpt
mysqli_character_set_name_oo.phpt
mysqli_close.phpt mysqli_close_oo.phpt
mysqli_commit.phpt mysqli_commit_oo.phpt
mysqli_constants.phpt
mysqli_constants_categories.phpt
mysqli_data_seek.phpt
mysqli_data_seek_oo.phpt
mysqli_debug.phpt
mysqli_disable_reads_from_master.phpt
mysqli_disable_rpl_parse.phpt
mysqli_driver.phpt
mysqli_dump_debug_info.phpt
mysqli_dump_debug_info_oo.phpt
mysqli_embedded_connect.phpt
mysqli_enable_reads_from_master.phpt
mysqli_enable_rpl_parse.phpt
mysqli_errno.phpt mysqli_errno_oo.phpt
mysqli_error.phpt mysqli_error_oo.phpt
mysqli_error_unicode.phpt
mysqli_explain_metadata.phpt
mysqli_fetch_lengths.phpt
mysqli_fetch_lengths_oo.phpt
mysqli_field_count.phpt
mysqli_field_seek.phpt
mysqli_field_tell.phpt
mysqli_free_result.phpt
mysqli_get_charset.phpt
mysqli_get_client_info.phpt
mysqli_get_client_version.phpt
mysqli_get_connection_stats.phpt
mysqli_get_host_info.phpt
mysqli_get_proto_info.phpt
mysqli_get_server_info.phpt
mysqli_get_server_version.phpt
mysqli_get_warnings.phpt mysqli_info.phpt
mysqli_init.phpt mysqli_insert_id.phpt
mysqli_kill.phpt mysqli_more_results.phpt
mysqli_multi_query.phpt
mysqli_mysqli_result_invalid_mode.phpt
mysqli_next_result.phpt
mysqli_num_fields.phpt
mysqli_num_rows.phpt mysqli_options.phpt
mysqli_options_init_command.phpt
mysqli_pconnect.phpt mysqli_phpinfo.phpt
mysqli_ping.phpt mysqli_prepare.phpt
mysqli_prepare_no_object.phpt
mysqli_query.phpt
mysqli_query_unicode.phpt
mysqli_real_escape_string.phpt
mysqli_real_escape_string_unicode.phpt
mysqli_real_query.phpt mysqli_report.phpt
mysqli_report_wo_ps.phpt
mysqli_result_references.phpt
mysqli_result_references_mysqlnd.phpt
mysqli_rollback.phpt
mysqli_select_db.phpt
mysqli_set_charset.phpt
mysqli_set_opt.phpt
mysqli_set_opt_numeric_and_datetime_as_unicode.phpt
mysqli_sqlstate.phpt mysqli_ssl_set.phpt
mysqli_stat.phpt
mysqli_stmt_affected_rows.phpt
mysqli_stmt_attr_get.phpt
mysqli_stmt_attr_get_prefetch.phpt
mysqli_stmt_attr_set.phpt
mysqli_stmt_bind_param.phpt
mysqli_stmt_bind_param_references.phpt
mysqli_stmt_bind_param_type_juggling.phpt
mysqli_stmt_bind_result.phpt
mysqli_stmt_bind_result_bit.phpt
mysqli_stmt_bind_result_references.phpt
mysqli_stmt_close.phpt
mysqli_stmt_data_seek.phpt
mysqli_stmt_errno.phpt
mysqli_stmt_error.phpt
mysqli_stmt_execute.phpt
mysqli_stmt_fetch.phpt
mysqli_stmt_fetch_bit.phpt
mysqli_stmt_fetch_fields_win32_unicode.phpt
mysqli_stmt_field_count.phpt
mysqli_stmt_free_result.phpt
mysqli_stmt_get_warnings.phpt
mysqli_stmt_init.phpt
mysqli_stmt_insert_id.phpt
mysqli_stmt_num_rows.phpt
mysqli_stmt_param_count.phpt
mysqli_stmt_prepare.phpt
mysqli_stmt_reset.phpt
mysqli_stmt_result_metadata.phpt
mysqli_stmt_result_metadata_sqltests.phpt
mysqli_stmt_sqlstate.phpt
mysqli_stmt_store_result.phpt
mysqli_store_result.phpt
mysqli_thread_id.phpt
mysqli_thread_safe.phpt
mysqli_use_result.phpt
mysqli_warning_count.phpt
Modified files:
/php-src/ext/mysqli/tests mysqli_autocommit.phpt
mysqli_autocommit_oo.phpt
Log:
Damn, Pierre is clever.
[14:35] <_jani_> nixnutz_: why don't you just commit everything in one go..?
[14:35] <_jani_> this "spamming" is getting quite boring..
[14:36] <Pierre> 20â¬/commit :)
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_autocommit.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/mysqli/tests/mysqli_autocommit.phpt diff -u php-src/ext/mysqli/tests/mysqli_autocommit.phpt:1.1 php-src/ext/mysqli/tests/mysqli_autocommit.phpt:1.2 --- php-src/ext/mysqli/tests/mysqli_autocommit.phpt:1.1 Thu Jul 12 20:20:57 2007 +++ php-src/ext/mysqli/tests/mysqli_autocommit.phpt Mon Jul 23 12:38:40 2007 @@ -146,7 +146,7 @@ if (NULL !== ($tmp = @mysqli_autocommit($link, false))) printf("[033] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); - print "done!\n"; + print "done!"; ?> --EXPECTF-- done! \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_autocommit_oo.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/mysqli/tests/mysqli_autocommit_oo.phpt diff -u php-src/ext/mysqli/tests/mysqli_autocommit_oo.phpt:1.1 php-src/ext/mysqli/tests/mysqli_autocommit_oo.phpt:1.2 --- php-src/ext/mysqli/tests/mysqli_autocommit_oo.phpt:1.1 Thu Jul 12 20:20:57 2007 +++ php-src/ext/mysqli/tests/mysqli_autocommit_oo.phpt Mon Jul 23 12:38:40 2007 @@ -135,7 +135,7 @@ if (NULL !== ($tmp = @$mysqli->autocommit( false))) printf("[030] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); - print "done!\n"; + print "done!"; ?> --EXPECTF-- done! \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_change_user.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_change_user.phpt +++ php-src/ext/mysqli/tests/mysqli_change_user.phpt --TEST-- mysqli_change_user() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_change_user())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_change_user($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_change_user($link, $link))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_change_user($link, $link, $link))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_change_user($link, $link, $link, $link, $link))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[006] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (false !== ($tmp = mysqli_change_user($link, $user . '_unknown_really', $passwd . 'non_empty', $db))) printf("[007] Expecting false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysqli_change_user($link, $user, $passwd . '_unknown_really', $db))) printf("[008] Expecting false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysqli_change_user($link, $user, $passwd, $db . '_unknown_really'))) printf("[009] Expecting false, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, 'SET @mysqli_change_user_test_var=1')) printf("[010] Failed to set test variable: [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$res = mysqli_query($link, 'SELECT @mysqli_change_user_test_var AS test_var')) printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); if (1 != $tmp['test_var']) printf("[012] Cannot set test variable\n"); if (true !== ($tmp = mysqli_change_user($link, $user, $passwd, $db))) printf("[013] Expecting true, got %s/%s\n", gettype($tmp), $tmp); if (!$res = mysqli_query($link, 'SELECT database() AS dbname, user() AS user')) printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); if (substr($tmp['user'], 0, strlen($user)) !== $user) printf("[015] Expecting user %s, got user() %s\n", $user, $tmp['user']); if ($tmp['dbname'] != $db) printf("[016] Expecting database %s, got database() %s\n", $db, $tmp['dbname']); if (!$res = mysqli_query($link, 'SELECT @mysqli_change_user_test_var AS test_var')) printf("[017] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); if (NULL !== $tmp['test_var']) printf("[019] Test variable is still set!\n"); mysqli_close($link); if (NULL !== ($tmp = @mysqli_change_user($link, $user, $passwd, $db))) printf("[020] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_change_user_oo.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_change_user_oo.phpt +++ php-src/ext/mysqli/tests/mysqli_change_user_oo.phpt --TEST-- mysqli->change_user() --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('table.inc'); if (!$IS_MYSQLND && (mysqli_get_server_version($link) < 50118 && mysqli_get_server_version($link) > 50100)) { die("skip Your MySQL Server version has a known but that will cause a crash"); } ?> --FILE-- <?php include_once("connect.inc"); $link = NULL; $tmp = NULL; if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (!is_null($tmp = @$mysqli->change_user())) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @$mysqli->change_user($link))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @$mysqli->change_user($link, $link))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @$mysqli->change_user($link, $link, $link, $link))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = $mysqli->change_user($user . '_unknown_really', $passwd . 'non_empty', $db))) printf("[006] Expecting false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = $mysqli->change_user($user, $passwd . '_unknown_really', $db))) printf("[007] Expecting false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = $mysqli->change_user($user, $passwd, $db . '_unknown_really'))) printf("[008] Expecting false, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query('SET @mysqli_change_user_test_var=1')) printf("[009] Failed to set test variable: [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$res = $mysqli->query('SELECT @mysqli_change_user_test_var AS test_var')) printf("[010] [%d] %s\n", $mysqli->errno, $mysqli->error); $tmp = $res->fetch_assoc(); $res->free_result(); if (1 != $tmp['test_var']) printf("[011] Cannot set test variable\n"); if (true !== ($tmp = $mysqli->change_user($user, $passwd, $db))) printf("[012] Expecting true, got %s/%s\n", gettype($tmp), $tmp); if (!$res = $mysqli->query('SELECT database() AS dbname, user() AS user')) printf("[013] [%d] %s\n", $mysqli->errno, $mysqli->error); $tmp = $res->fetch_assoc(); $res->free_result(); if (substr($tmp['user'], 0, strlen($user)) !== $user) printf("[014] Expecting user %s, got user() %s\n", $user, $tmp['user']); if ($tmp['dbname'] != $db) printf("[015] Expecting database %s, got database() %s\n", $db, $tmp['dbname']); if (!$res = $mysqli->query('SELECT @mysqli_change_user_test_var AS test_var')) printf("[016] [%d] %s\n", $mysqli->errno, $mysqli->error); $tmp = $res->fetch_assoc(); $res->free_result(); if (NULL !== $tmp['test_var']) printf("[017] Test variable is still set!\n"); $mysqli->close(); if (NULL !== ($tmp = @$mysqli->change_user($user, $passwd, $db))) printf("[018] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_character_set.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_character_set.phpt +++ php-src/ext/mysqli/tests/mysqli_character_set.phpt --TEST-- Fetching results from tables of different charsets. --SKIPIF-- <?php require_once('skipifunicode.inc'); ?> <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (ini_get("unicode.semantics")){ die('done!'); } if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (!$res = mysqli_query($link, 'SELECT version() AS server_version')) printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); $version = explode('.', $tmp['server_version']); if (empty($version)) printf("[003] Cannot determine server version, need MySQL Server 4.1+ for the test!\n"); if ($version[0] <= 4 && $version[1] < 1) printf("[004] Need MySQL Server 4.1+ for the test!\n"); if (!$res = mysqli_query($link, "SHOW CHARACTER SET")) printf("[005] Cannot get list of available character sets, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $charsets = array(); while ($row = mysqli_fetch_assoc($res)) $charsets[] = $row; mysqli_free_result($res); foreach ($charsets as $k => $charset) { /* The server currently 17.07.2007 can't handle data sent in ucs2 */ if ($charset['Charset'] == 'ucs2') { continue; } if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) printf("[006 + %d] [%d] %s\n", $k, mysqli_errno($link), mysqli_error($link)); $sql = sprintf("CREATE TABLE test(id INT, label CHAR(1)) CHARACTER SET '%s' ", $charset['Charset']); if (!mysqli_query($link, $sql)) { printf("[007 + %d] %s [%d] %s\n", $k, $sql, mysqli_errno($link), mysqli_error($link)); continue; } if (!mysqli_set_charset($link, $charset['Charset'])) { printf("[008 + %d] [%d] %s\n", $k, mysqli_errno($link), mysqli_error($link)); continue; } for ($i = 1; $i <= 3; $i++) { if (!mysqli_query($link, sprintf("INSERT INTO test (id, label) VALUES (%d, '%s')", $i, mysqli_real_escape_string($link, chr(ord("a") + $i))))) { var_dump($charset['Charset']); printf("[009 + %d] [%d] %s\n", $k, mysqli_errno($link), mysqli_error($link)); continue; } } if (!$res = mysqli_query($link, "SELECT id, label FROM test")) printf("[010 + %d] [%d] %s\n", $k, mysqli_errno($link), mysqli_error($link)); for ($i = 1; $i <= 3; $i++) { if (!$tmp = mysqli_fetch_assoc($res)) printf("[011 + %d] [%d] %s\n", $k, mysqli_errno($link), mysqli_error($link)); if ($tmp['id'] != $i) printf("[012 + %d] Expecting %d, got %s, [%d] %s\n", $k, $i, $tmp['id'], mysqli_errno($link), mysqli_error($link)); if ($tmp['label'] != chr(ord("a") + $i)) printf("[013 + %d] Expecting %d, got %s, [%d] %s\n", $k, chr(ord("a") + $i), $tmp['label'], mysqli_errno($link), mysqli_error($link)); } mysqli_free_result($res); } mysqli_close($link); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_character_set_name.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_character_set_name.phpt +++ php-src/ext/mysqli/tests/mysqli_character_set_name.phpt --TEST-- mysqli_chararcter_set_name(), mysql_client_encoding() [alias] --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php /* NOTE: http://bugs.mysql.com/bug.php?id=7923 makes this test fail very likely on all 4.1.x - 5.0.x! */ include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_character_set_name())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_character_set_name($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_character_set_name($link, $link, $link))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[005] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (!$res = mysqli_query($link, 'SELECT version() AS server_version')) printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); $version = explode('.', $tmp['server_version']); if (empty($version)) printf("[006] Cannot determine server version, need MySQL Server 4.1+ for the test!\n"); if ($version[0] <= 4 && $version[1] < 1) printf("[007] Need MySQL Server 4.1+ for the test!\n"); if (!$res = mysqli_query($link, 'SELECT @@character_set_connection AS charset, @@collation_connection AS collation')) printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); if (!$tmp['charset']) printf("[009] Cannot determine current character set and collation\n"); $charset = mysqli_character_set_name($link); if ($tmp['charset'] !== $charset) { if ($tmp['collation'] === $charset) { printf("[010] Could be known server bug http://bugs.mysql.com/bug.php?id=7923, collation %s instead of character set returned, expected string/%s, got %s/%s\n", $tmp['collation'], $tmp['charset'], gettype($charset), $charset); } else { printf("[011] Expecting character set %s/%s, got %s/%s\n", gettype($tmp['charset']), $tmp['charset'], gettype($charset), $charset); } } $charset2 = mysqli_client_encoding($link); if ($charset2 !== $charset) { printf("[012] Alias mysqli_client_encoding returned %s/%s, expected %s/%s\n", gettype($charset2), $charset2, gettype($charset), $charset); } mysqli_close($link); if (NULL !== ($tmp = @mysqli_character_set_name($link))) printf("[013] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); /* Make sure that the function alias exists */ if (!is_null($tmp = @mysqli_client_encoding())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_character_set_name_oo.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_character_set_name_oo.phpt +++ php-src/ext/mysqli/tests/mysqli_character_set_name_oo.phpt --TEST-- mysqli_chararcter_set_name(), mysql_client_encoding() [alias] --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php /* NOTE: http://bugs.mysql.com/bug.php?id=7923 makes this test fail very likely on all 4.1.x - 5.0.x! */ include "connect.inc"; $tmp = NULL; $link = NULL; if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (!is_null($tmp = @$mysqli->character_set_name($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$res = $mysqli->query('SELECT version() AS server_version')) printf("[003] [%d] %s\n", $mysqli->errno, $mysqli->error); $tmp = $res->fetch_assoc(); $res->free_result(); $version = explode('.', $tmp['server_version']); if (empty($version)) printf("[006] Cannot determine server version, need MySQL Server 4.1+ for the test!\n"); if ($version[0] <= 4 && $version[1] < 1) printf("[007] Need MySQL Server 4.1+ for the test!\n"); if (!$res = $mysqli->query('SELECT @@character_set_connection AS charset, @@collation_connection AS collation')) printf("[008] [%d] %s\n", $mysqli->errno, $mysqli->error); $tmp = $res->fetch_assoc(); $res->free_result(); if (!$tmp['charset']) printf("[009] Cannot determine current character set and collation\n"); $charset = $mysqli->character_set_name(); if ($tmp['charset'] !== $charset) { if ($tmp['collation'] === $charset) { printf("[010] Could be known server bug http://bugs.mysql.com/bug.php?id=7923, collation %s instead of character set returned, expected string/%s, got %s/%s\n", $tmp['collation'], $tmp['charset'], gettype($charset), $charset); } else { printf("[011] Expecting character set %s/%s, got %s/%s\n", gettype($tmp['charset']), $tmp['charset'], gettype($charset), $charset); } } $charset2 = $mysqli->character_set_name(); if ($charset2 !== $charset) { printf("[012] Alias mysqli_client_encoding returned %s/%s, expected %s/%s\n", gettype($charset2), $charset2, gettype($charset), $charset); } $mysqli->close(); if (NULL !== ($tmp = @$mysqli->character_set_name())) printf("[013] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); /* Make sure that the function alias exists */ if (!is_null($tmp = @$mysqli->client_encoding())) printf("[014] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_close.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_close.phpt +++ php-src/ext/mysqli/tests/mysqli_close.phpt --TEST-- mysqli_close() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_close())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_close($link, $link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_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 = @mysqli_close(NULL); if (NULL !== $tmp) printf("[004] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); $tmp = mysqli_close($link); if (true !== $tmp) printf("[005] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_query($link, "SELECT 1"))) printf("[006] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_close_oo.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_close_oo.phpt +++ php-src/ext/mysqli/tests/mysqli_close_oo.phpt --TEST-- mysqli_close() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (!is_null($tmp = @$mysqli->close($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); $tmp = $mysqli->close(); if (true !== $tmp) printf("[003] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @$mysqli->close())) printf("[004] Expecting NULL got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @$mysqli->query("SELECT 1"))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_commit.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_commit.phpt +++ php-src/ext/mysqli/tests/mysqli_commit.phpt --TEST-- mysqli_commit() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> <?PHP if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { die(sprintf("skip Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket)); } if (!$res = mysqli_query($link, "SHOW VARIABLES LIKE 'have_innodb'")) { die(sprintf("skip Cannot fetch have_innodb variable\n")); } $row = mysqli_fetch_row($res); mysqli_free_result($res); mysqli_close($link); if ($row[1] == "DISABLED" || $row[1] == "NO") { die(sprintf ("skip Innodb support is not installed or enabled.")); } ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_commit())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_commit($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_commit($link, $link))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_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 (true !== ($tmp = mysqli_autocommit($link, false))) printf("[005] Cannot turn off autocommit, expecting true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, 'CREATE TABLE test(id INT) ENGINE = InnoDB')) printf("[007] Cannot create test table, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, 'INSERT INTO test(id) VALUES (1)')) printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_commit($link); if ($tmp !== true) printf("[009] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, 'ROLLBACK')) printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$res = mysqli_query($link, 'SELECT COUNT(*) AS num FROM test')) printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); if (1 != $tmp['num']) printf("[12] Expecting 1 row in table test, found %d rows\n", $tmp['num']); mysqli_free_result($res); if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_close($link); if (NULL !== ($tmp = @mysqli_commit($link))) printf("[014] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_commit_oo.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_commit_oo.phpt +++ php-src/ext/mysqli/tests/mysqli_commit_oo.phpt --TEST-- mysqli_commit() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> <?PHP if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) { die(sprintf("skip Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket)); } if (!$res = $mysqli->query("SHOW VARIABLES LIKE 'have_innodb'")) { die(sprintf("skip Cannot fetch have_innodb variable\n")); } $row = $res->fetch_row(); $res->free(); $mysqli->close(); if ($row[1] == "DISABLED" || $row[1] == "NO") { die(sprintf("skip Innodb support is not installed or enabled.")); } ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; $mysqli = new mysqli(); if (!is_null($tmp = @$mysqli->commit())) printf("[013] Expecting NULL got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (!is_null($tmp = @$mysqli->commit($link))) printf("[002] Expecting NULL/NULL, got %s/%s, [%d] %s\n", gettype($tmp), $tmp, $mysqli->errno, $mysqli->error); if (true !== ($tmp = $mysqli->commit())) printf("[014] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = $mysqli->autocommit(false))) printf("[003] Cannot turn off autocommit, expecting true, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query('DROP TABLE IF EXISTS test')) printf("[004] [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$mysqli->query('CREATE TABLE test(id INT) ENGINE = InnoDB')) printf("[005] Cannot create test table, [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$mysqli->query('INSERT INTO test(id) VALUES (1)')) printf("[006] [%d] %s\n", $mysqli->errno, $mysqli->error); $tmp = $mysqli->commit(); if ($tmp !== true) printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query('ROLLBACK')) printf("[008] [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$res = $mysqli->query('SELECT COUNT(*) AS num FROM test')) printf("[009] [%d] %s\n", $mysqli->errno, $mysqli->error); $tmp = $res->fetch_assoc(); if (1 != $tmp['num']) printf("[010] Expecting 1 row in table test, found %d rows\n", $tmp['num']); $res->free(); if (!$mysqli->query('DROP TABLE IF EXISTS test')) printf("[011] [%d] %s\n", $mysqli->errno, $mysqli->error); $mysqli->close(); if (NULL !== ($tmp = @$mysqli->commit())) printf("[012] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_constants.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_constants.phpt +++ php-src/ext/mysqli/tests/mysqli_constants.phpt --TEST-- Constants exported by ext/mysqli --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php require("connect.inc"); require("table.inc"); $php_version = (int)str_replace('.', '', PHP_VERSION); $constants = get_defined_constants(true); sort($constants); $expected_constants = array( 'MYSQLI_READ_DEFAULT_GROUP' => true, 'MYSQLI_READ_DEFAULT_FILE' => true, 'MYSQLI_OPT_CONNECT_TIMEOUT' => true, 'MYSQLI_OPT_LOCAL_INFILE' => true, 'MYSQLI_INIT_COMMAND' => true, 'MYSQLI_CLIENT_SSL' => true, "MYSQLI_CLIENT_COMPRESS" => true, "MYSQLI_CLIENT_INTERACTIVE" => true, "MYSQLI_CLIENT_IGNORE_SPACE" => true, "MYSQLI_CLIENT_NO_SCHEMA" => true, "MYSQLI_CLIENT_FOUND_ROWS" => true, "MYSQLI_STORE_RESULT" => true, "MYSQLI_USE_RESULT" => true, "MYSQLI_ASSOC" => true, "MYSQLI_NUM" => true, "MYSQLI_BOTH" => true, "MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH" => true, "MYSQLI_NOT_NULL_FLAG" => true, "MYSQLI_PRI_KEY_FLAG" => true, "MYSQLI_UNIQUE_KEY_FLAG" => true, "MYSQLI_MULTIPLE_KEY_FLAG" => true, "MYSQLI_BLOB_FLAG" => true, "MYSQLI_UNSIGNED_FLAG" => true, "MYSQLI_ZEROFILL_FLAG" => true, "MYSQLI_AUTO_INCREMENT_FLAG" => true, "MYSQLI_TIMESTAMP_FLAG" => true, "MYSQLI_SET_FLAG" => true, "MYSQLI_NUM_FLAG" => true, "MYSQLI_PART_KEY_FLAG" => true, "MYSQLI_GROUP_FLAG" => true, "MYSQLI_TYPE_DECIMAL" => true, "MYSQLI_TYPE_TINY" => true, "MYSQLI_TYPE_SHORT" => true, "MYSQLI_TYPE_LONG" => true, "MYSQLI_TYPE_FLOAT" => true, "MYSQLI_TYPE_DOUBLE" => true, "MYSQLI_TYPE_NULL" => true, "MYSQLI_TYPE_TIMESTAMP" => true, "MYSQLI_TYPE_LONGLONG" => true, "MYSQLI_TYPE_INT24" => true, "MYSQLI_TYPE_DATE" => true, "MYSQLI_TYPE_TIME" => true, "MYSQLI_TYPE_DATETIME" => true, "MYSQLI_TYPE_YEAR" => true, "MYSQLI_TYPE_NEWDATE" => true, "MYSQLI_TYPE_ENUM" => true, "MYSQLI_TYPE_SET" => true, "MYSQLI_TYPE_TINY_BLOB" => true, "MYSQLI_TYPE_MEDIUM_BLOB" => true, "MYSQLI_TYPE_LONG_BLOB" => true, "MYSQLI_TYPE_BLOB" => true, "MYSQLI_TYPE_VAR_STRING" => true, "MYSQLI_TYPE_STRING" => true, "MYSQLI_TYPE_CHAR" => true, "MYSQLI_TYPE_INTERVAL" => true, "MYSQLI_TYPE_GEOMETRY" => true, "MYSQLI_NO_DATA" => true, "MYSQLI_REPORT_INDEX" => true, "MYSQLI_REPORT_STRICT" => true, "MYSQLI_REPORT_ALL" => true, "MYSQLI_REPORT_ERROR" => true, "MYSQLI_REPORT_OFF" => true, "MYSQLI_SET_CHARSET_NAME" => true, ); /* depends on the build - experimental */ if ($IS_MYSQLND && defined('MYSQLI_OPT_INT_AND_YEARS_AS_INT')) $expected_constants['MYSQLI_OPT_INT_AND_YEARS_AS_INT'] = true; if ($IS_MYSQLND) { $version = 50007 + 1; } else { $version = mysqli_get_client_version(); } if ($version > 50002) { $expected_constants = array_merge($expected_constants, array( "MYSQLI_TYPE_NEWDECIMAL" => true, "MYSQLI_TYPE_BIT" => true, )); } if ($version > 50003) { $expected_constants = array_merge($expected_constants, array( "MYSQLI_STMT_ATTR_CURSOR_TYPE" => true, "MYSQLI_CURSOR_TYPE_NO_CURSOR" => true, "MYSQLI_CURSOR_TYPE_READ_ONLY" => true, "MYSQLI_CURSOR_TYPE_FOR_UPDATE" => true, "MYSQLI_CURSOR_TYPE_SCROLLABLE" => true, )); } if ($version > 50007) { $expected_constants = array_merge($expected_constants, array( "MYSQLI_STMT_ATTR_PREFETCH_ROWS" => true, )); } /* pretty dump test, but that is the best way to mimic mysql.c */ if (defined('MYSQLI_DATA_TRUNCATED')) $expected_constants["MYSQLI_DATA_TRUNCATED"] = true; if ($IS_MYSQLND && $php_version >= 600) { /* mysqlnd only */ $expected_constants["MYSQLI_OPT_NUMERIC_AND_DATETIME_AS_UNICODE"] = true; } else if (!$IS_MYSQLND) { /* libmysql only */ /* are they available in all versions of ext/mysqli ? */ $expected_constants["MYSQLI_RPL_MASTER"] = true; $expected_constants["MYSQLI_RPL_SLAVE"] = true; $expected_constants["MYSQLI_RPL_ADMIN"] = true; } $unexpected_constants = array(); foreach ($constants as $group => $consts) { foreach ($consts as $name => $value) { if (stristr($name, 'mysqli')) { $name = strtoupper($name); if (isset($expected_constants[$name])) { unset($expected_constants[$name]); } else { $unexpected_constants[$name] = $name; } } } } if (!empty($unexpected_constants)) { printf("Dumping list of unexpected constants\n"); var_dump($unexpected_constants); } if (!empty($expected_constants)) { printf("Dumping list of missing constants\n"); var_dump($expected_constants); } print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_constants_categories.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_constants_categories.phpt +++ php-src/ext/mysqli/tests/mysqli_constants_categories.phpt --TEST-- Constants exported by ext/mysqli - checking category - PHP bug not mysqli bug (check from time to time) --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('connect.inc'); if (!$TEST_EXPERIMENTAL) die("skip This hits a known PHP bug, run the test from time to time and enable it once PHP got fixed"); ?> --FILE-- <?php require("connect.inc"); require("table.inc"); $constants = get_defined_constants(true); foreach ($constants as $group => $consts) { foreach ($consts as $name => $value) { if (stristr($name, 'mysqli')) { if ('mysqli' !== $group) printf("found constant '%s' in group '%s'. expecting group 'mysqli'\n", $name, $group); } } } print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_data_seek.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_data_seek.phpt +++ php-src/ext/mysqli/tests/mysqli_data_seek.phpt --TEST-- mysqli_data_seek() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (NULL !== ($tmp = @mysqli_data_seek())) printf("[001] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_data_seek($link))) printf("[002] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_data_seek($link, $link))) printf("[003] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysqli_query($link, 'SELECT * FROM test ORDER BY id LIMIT 4', MYSQLI_STORE_RESULT)) printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (true !== ($tmp = mysqli_data_seek($res, 3))) printf("[005] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); $row = mysqli_fetch_assoc($res); if (4 != $row['id']) printf("[006] Expecting record 4/d, got record %s/%s\n", $row['id'], $row['label']); if (true !== ($tmp = mysqli_data_seek($res, 0))) printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); $row = mysqli_fetch_assoc($res); if (1 != $row['id']) printf("[008] Expecting record 1/a, got record %s/%s\n", $row['id'], $row['label']); if (false !== ($tmp = mysqli_data_seek($res, 4))) printf("[009] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysqli_data_seek($res, -1))) printf("[010] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); mysqli_free_result($res); if (!$res = mysqli_query($link, 'SELECT * FROM test ORDER BY id', MYSQLI_USE_RESULT)) printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (false !== ($tmp = mysqli_data_seek($res, 3))) printf("[012] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); mysqli_free_result($res); if (NULL !== ($tmp = mysqli_data_seek($res, 1))) printf("[013] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); print "done!"; ?> --EXPECTF-- Warning: mysqli_data_seek(): Function cannot be used with MYSQL_USE_RESULT in %s on line %d Warning: mysqli_data_seek(): Couldn't fetch mysqli_result in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_data_seek_oo.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_data_seek_oo.phpt +++ php-src/ext/mysqli/tests/mysqli_data_seek_oo.phpt --TEST-- mysqli_result->data_seek() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; require('table.inc'); if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); $res = new mysqli_result($mysqli); if (NULL !== ($tmp = @$res->data_seek(0))) printf("[002] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$res = $mysqli->query('SELECT * FROM test ORDER BY id LIMIT 4', MYSQLI_STORE_RESULT)) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (NULL !== ($tmp = @$res->data_seek())) printf("[004] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @$res->data_seek($link))) printf("[005] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @$res->data_seek($link, $link))) printf("[006] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = $res->data_seek(3))) printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); $row = $res->fetch_assoc(); if (4 != $row['id']) printf("[008] Expecting record 4/d, got record %s/%s\n", $row['id'], $row['label']); if (true !== ($tmp = $res->data_seek(0))) printf("[009] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); $row = $res->fetch_assoc(); if (1 != $row['id']) printf("[010] Expecting record 1/a, got record %s/%s\n", $row['id'], $row['label']); if (false !== ($tmp = $res->data_seek(4))) printf("[011] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = $res->data_seek(-1))) printf("[012] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); $res->free_result(); if (!$res = $mysqli->query('SELECT * FROM test ORDER BY id', MYSQLI_USE_RESULT)) printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (false !== ($tmp = $res->data_seek(3))) printf("[014] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); $res->free_result(); if (NULL !== ($tmp = $res->data_seek(1))) printf("[015] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); $mysqli->close(); print "done!"; ?> --EXPECTF-- Warning: mysqli_result::data_seek(): Function cannot be used with MYSQL_USE_RESULT in %s on line %d Warning: mysqli_result::data_seek(): Couldn't fetch mysqli_result in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_debug.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_debug.phpt +++ php-src/ext/mysqli/tests/mysqli_debug.phpt --TEST-- mysqli_debug() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); if (!function_exists('mysqli_debug')) die("skip: mysqli_debug() not available"); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (NULL !== ($tmp = @mysqli_debug())) printf("[001] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); // NOTE: documentation is not clear on this: function always return NULL or TRUE if (true !== ($tmp = mysqli_debug("d:t:O,/tmp/client.trace"))) printf("[002] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_disable_reads_from_master.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_disable_reads_from_master.phpt +++ php-src/ext/mysqli/tests/mysqli_disable_reads_from_master.phpt --TEST-- mysqli_disable_reads_from_master() --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); if (!function_exists('mysqli_disable_reads_from_master')) { die("skip mysqli_disable_reads_from_master() not available"); } ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (NULL !== ($tmp = @mysqli_disable_reads_from_master())) printf("[001] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_disable_reads_from_master($link))) printf("[002] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_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); } if (!is_bool($tmp = mysqli_disable_reads_from_master($link))) printf("[004] Expecting boolean/[true|false] value, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); if (NULL !== ($tmp = mysqli_disable_reads_from_master($link))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_disable_reads_from_master(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_disable_rpl_parse.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_disable_rpl_parse.phpt +++ php-src/ext/mysqli/tests/mysqli_disable_rpl_parse.phpt --TEST-- mysqli_disable_rpl_parse() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> <?PHP if (!function_exists('mysqli_disable_rpl_parse')) die("skip mysqli_disable_rpl_parse() not available"); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (NULL !== ($tmp = @mysqli_disable_rpl_parse())) printf("[001] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_disable_rpl_parse($link))) printf("[002] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_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); } if (!is_bool($tmp = mysqli_disable_rpl_parse($link))) printf("[004] Expecting boolean/[true|false] value, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); if (NULL !== ($tmp = mysqli_disable_rpl_parse($link))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_disable_rpl_parse(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_driver.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_driver.phpt +++ php-src/ext/mysqli/tests/mysqli_driver.phpt --TEST-- mysqli_driver class --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; include "table.inc"; if (!is_object($driver = new mysqli_driver())) printf("[001] Failed to create mysqli_driver object\n"); $client_info = mysqli_get_client_info(); if (($tmp = $driver->client_info) !== $client_info) printf("[002] Expecting %s/%s, got %s/%s\n", gettype($client_info), $client_info, gettype($tmp), $tmp); $client_version = mysqli_get_client_version(); if (($tmp = $driver->client_version) !== $client_version) printf("[003] Expecting %s/%s, got %s/%s\n", gettype($client_version), $client_version, gettype($tmp), $tmp); if (!is_int($tmp = $driver->driver_version) || (0 == $tmp)) printf("[004] Expecting int/any, got %s/%s\n", gettype($tmp), $tmp); $all_modes = array(MYSQLI_REPORT_INDEX, MYSQLI_REPORT_ERROR, MYSQLI_REPORT_STRICT, MYSQLI_REPORT_ALL, MYSQLI_REPORT_OFF); $report_mode = $driver->report_mode; if (!is_int($report_mode)) printf("[005] Expecting int/any, got %s/%s\n", gettype($report_mode), $report_mode); if (!in_array($report_mode, $all_modes)) printf("[006] Illegal report mode returned? Got %s, expected %s\n", $report_mode, implode(', ', $all_modes)); $driver->report_mode = MYSQLI_REPORT_STRICT; $ok = false; try { if ($link = mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket)) printf("[007] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", $host, $user . 'unknown_really', $db, $port, $socket); mysqli_close($link); } catch (mysqli_sql_exception $e) { $ok = true; if ('' == $e->getMessage()) printf("[008] getMessage() has returned an emptry string.\n"); if ('' == $e->getCode()) printf("[009] getCode() has returned an empty string.\n"); if ('' == $e->getFile()) printf("[010] getFile() has returned an empty string.\n"); if ('' == $e->getLine()) printf("[011] getLine() has returned an empty string.\n"); $tmp = $e->getTrace(); if (empty($tmp)) printf("[012] getTrace() has returned an empty array.\n"); if ('' == $e->getTraceAsString()) printf("[013] getTraceAsString() has returned an empty string.\n"); if ('' == $e->__toString()) printf("[014] __toString() has returned an empty string.\n"); } if (!$ok) printf("[015] Error reporting mode has not been switched to exceptions and or no exception thrown\n"); $driver->report_mode = MYSQLI_REPORT_OFF; if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[016] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); mysqli_query($link, "NO_SQL"); mysqli_close($link); $driver->report_mode = MYSQLI_REPORT_ERROR; if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[017] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); mysqli_query($link, "NO_SQL"); mysqli_close($link); if (MYSQLI_REPORT_ERROR !== $driver->report_mode) printf("[018] Error mode should be different\n"); /* TODO - more report testing should go in here, but it's not really documented what behaviour is expected */ $driver->report_mode = $report_mode; $reconnect = $driver->reconnect; if (!is_bool($reconnect)) printf("[019] Expecting boolean/any, got %s/%s\n", gettype($reconnect), $reconnect); /* pointless, but I need more documentation */ $driver->reconnect = true; $driver->reconnect = false; $driver->reconnect = $reconnect; if (!is_bool($embedded = $driver->embedded)) printf("[020] Expecting boolean/any, got %s/%s\n", gettype($embedded), $embedded); print "done!"; ?> --EXPECTF-- Warning: mysqli_query(): (%d/%d): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NO_SQL' at line 1 in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_dump_debug_info.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_dump_debug_info.phpt +++ php-src/ext/mysqli/tests/mysqli_dump_debug_info.phpt --TEST-- mysqli_dump_debug_info() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (NULL !== ($tmp = @mysqli_dump_debug_info())) printf("[001] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_dump_debug_info($link))) printf("[002] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_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); exit(1); } if (!is_bool($tmp = mysqli_dump_debug_info($link))) printf("[004] Expecting boolean/[true|false] value, got %s/%s, [%d] %s\n", gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link)); mysqli_close($link); if (NULL !== ($tmp = mysqli_dump_debug_info($link))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link)); print "done!"; ?> --EXPECTF-- Warning: mysqli_dump_debug_info(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_dump_debug_info_oo.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_dump_debug_info_oo.phpt +++ php-src/ext/mysqli/tests/mysqli_dump_debug_info_oo.phpt --TEST-- mysqli_dump_debug_info() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (NULL !== ($tmp = @$mysqli->dump_debug_info($link))) printf("[002] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_bool($tmp = $mysqli->dump_debug_info())) printf("[003] Expecting boolean/[true|false] value, got %s/%s, [%d] %s\n", gettype($tmp), $tmp, $mysqli->errno, $mysqli->error); $mysqli->close(); if (NULL !== ($tmp = $mysqli->dump_debug_info())) printf("[004] Expecting NULL, got %s/%s, [%d] %s\n", gettype($tmp), $tmp, $mysqli->errno, $mysqli->error); print "done!"; ?> --EXPECTF-- Warning: mysqli::dump_debug_info(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_embedded_connect.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_embedded_connect.phpt +++ php-src/ext/mysqli/tests/mysqli_embedded_connect.phpt --TEST-- mysqli_embedded_connect() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifnotemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (NULL !== ($tmp = @mysqli_embedded_connect())) printf("[001] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_embedded_connect($db)) { 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 (!is_bool($tmp = mysqli_embedded_connect($db . '_unknown'))) printf("[003] Expecting boolean/[true|false] value, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); print "done!"; ?> --EXPECTF-- Warning: mysqli_embedded_connect() expects parameter 1 to be mysqli, null given in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_enable_reads_from_master.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_enable_reads_from_master.phpt +++ php-src/ext/mysqli/tests/mysqli_enable_reads_from_master.phpt --TEST-- mysqli_enable_reads_from_master() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> <?PHP if (!function_exists('mysqli_enable_reads_from_master')) { die("skip function mysqli_enable_reads_from_master() not available\n"); } ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (NULL !== ($tmp = @mysqli_enable_reads_from_master())) printf("[001] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_enable_reads_from_master($link))) printf("[002] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_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); } if (!is_bool($tmp = mysqli_enable_reads_from_master($link))) printf("[004] Expecting boolean/[true|false] value, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); if (NULL !== ($tmp = mysqli_enable_reads_from_master($link))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_enable_reads_from_master(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_enable_rpl_parse.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_enable_rpl_parse.phpt +++ php-src/ext/mysqli/tests/mysqli_enable_rpl_parse.phpt --TEST-- mysqli_enable_rpl_parse() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> <?PHP if (!function_exists('mysqli_enable_rpl_parse')) die("skip mysqli_enable_rpl_parse() not available"); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (NULL !== ($tmp = @mysqli_enable_rpl_parse())) printf("[001] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_enable_rpl_parse($link))) printf("[002] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_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); } if (!is_bool($tmp = mysqli_enable_rpl_parse($link))) printf("[004] Expecting boolean/[true|false] value, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); if (NULL !== ($tmp = mysqli_enable_rpl_parse($link))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_enable_rpl_parse(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_errno.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_errno.phpt +++ php-src/ext/mysqli/tests/mysqli_errno.phpt --TEST-- mysqli_errno() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_errno())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_errno($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_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); } var_dump(mysqli_errno($link)); if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) { printf("[004] Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } mysqli_query($link, 'SELECT * FROM test'); var_dump(mysqli_errno($link)); @mysqli_query($link, 'No SQL'); if (($tmp = mysqli_errno($link)) == 0) printf("[005] Expecting int/any non zero got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); var_dump(mysqli_errno($link)); print "done!"; ?> --EXPECTF-- int(0) int(%d) Warning: mysqli_errno(): Couldn't fetch mysqli in %s on line %d NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_errno_oo.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_errno_oo.phpt +++ php-src/ext/mysqli/tests/mysqli_errno_oo.phpt --TEST-- $mysqli->errno --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; $mysqli = new mysqli(); if (!is_null($tmp = @$mysqli->errno)) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli = new mysqli($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); var_dump($mysqli->errno); if (!$mysqli->query('DROP TABLE IF EXISTS test')) { printf("[003] Failed to drop old test table: [%d] %s\n", $mysqli->errno, $mysqli->error); } $mysqli->query('SELECT * FROM test'); var_dump($mysqli->errno); @$mysqli->query('No SQL'); if (($tmp = $mysqli->errno) === 0) printf("[004] Expecting int/any non zero got %s/%s\n", gettype($tmp), $tmp); $mysqli->close(); var_dump($mysqli->errno); print "done!"; ?> --EXPECTF-- int(0) int(%d) Warning: main(): Couldn't fetch mysqli in %s on line %d NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_error.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_error.phpt +++ php-src/ext/mysqli/tests/mysqli_error.phpt --TEST-- mysqli_error() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_error())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_error($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_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 = mysqli_error($link); if (!is_string($tmp) || ('' !== $tmp)) printf("[004] Expecting string/empty, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) { printf("[005] Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } mysqli_query($link, 'SELECT * FROM test'); $tmp = mysqli_error($link); if (!is_string($tmp) || !preg_match("/Table '\w*\.test' doesn't exist/su", $tmp)) printf("[006] Expecting string/[Table... doesn't exit], got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link)); mysqli_close($link); var_dump(mysqli_error($link)); print "done!"; ?> --EXPECTF-- Warning: mysqli_error(): Couldn't fetch mysqli in %s on line %d NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_error_oo.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_error_oo.phpt +++ php-src/ext/mysqli/tests/mysqli_error_oo.phpt --TEST-- $mysqli->error --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; $mysqli = new mysqli(); if (!is_null($tmp = @$mysqli->error)) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli = new mysqli($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); $tmp = $mysqli->error; if (!is_string($tmp) || ('' !== $tmp)) printf("[003] Expecting string/empty, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, $mysqli->errno, $mysqli->error); if (!$mysqli->query('DROP TABLE IF EXISTS test')) { printf("[004] Failed to drop old test table: [%d] %s\n", $mysqli->errno, $mysqli->error); } $mysqli->query('SELECT * FROM test'); $tmp = $mysqli->error; if (!is_string($tmp) || !preg_match("/Table '\w*\.test' doesn't exist/su", $tmp)) printf("[006] Expecting string/[Table... doesn't exit], got %s/%s. [%d] %s\n", gettype($tmp), $tmp, $mysqli->errno, $mysqli->error); $mysqli->close(); var_dump($mysqli->error); print "done!"; ?> --EXPECTF-- Warning: main(): Couldn't fetch mysqli in %s on line %d NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_error_unicode.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_error_unicode.phpt +++ php-src/ext/mysqli/tests/mysqli_error_unicode.phpt --TEST-- mysqli_error() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_error())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_error($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_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); } if (!ini_get("unicode.semantics")) { mysqli_query($link, "set names utf8"); } $tmp = mysqli_error($link); if (!is_string($tmp) || ('' !== $tmp)) printf("[004] Expecting string/empty, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link)); mysqli_query($link, 'SELECT * FROM нÑма_Ñакава_ÑаблиÑа'); $tmp = mysqli_error($link); var_dump(str_replace($db.".", "", $tmp)); mysqli_close($link); var_dump(mysqli_error($link)); print "done!"; ?> --EXPECTF-- string(58) "Table 'нÑма_Ñакава_ÑаблиÑа' doesn't exist" Warning: mysqli_error(): Couldn't fetch mysqli in %s on line %d NULL done! --UEXPECTF-- unicode(41) "Table 'нÑма_Ñакава_ÑаблиÑа' doesn't exist" Warning: mysqli_error(): Couldn't fetch mysqli in %s on line %d NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_explain_metadata.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_explain_metadata.phpt +++ php-src/ext/mysqli/tests/mysqli_explain_metadata.phpt --TEST-- EXPLAIN - metadata --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php require_once('connect.inc'); require_once('table.inc'); if (!$res = mysqli_query($link, 'EXPLAIN SELECT t1.*, t2.* FROM test AS t1, test AS t2')) printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $num_rows = 0; $num_fields = 0; $field_names = array(); if (!$row = mysqli_fetch_assoc($res)) { printf("[002] Expecting result but got no data [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } else { $num_rows++; $num_fields = count($row); foreach ($row as $name => $value) $field_names[$name] = gettype($value); } while ($row = mysqli_fetch_assoc($res)) $num_rows++; if (($tmp = mysqli_num_rows($res)) !== $num_rows) { printf("[003] Expecting int/%d got %s/%s\n", $num_rows, gettype($tmp), $tmp); } if (($tmp = mysqli_field_count($link)) !== $num_fields) { printf("[004] Expecting int/%d got %s/%s\n", $num_fields, gettype($tmp), $tmp); } $fields = mysqli_fetch_fields($res); if (($tmp = count($fields)) !== $num_fields) { printf("[005] Expecting int/%d got %s/%s\n", $num_fields, gettype($tmp), $tmp); } foreach ($fields as $k => $field) { $field->max_length = 0;// change it or we will get diff error if (isset($field_names[$field->name])) { unset($field_names[$field->name]); } else { printf("[006] Unexpected field '%s', dumping info\n"); var_dump($field); } } if (!empty($field_names)) { printf("[007] Field descriptions missing for the following columns\n"); var_dump($field_names); } mysqli_free_result($res); $stmt = mysqli_stmt_init($link); /* Depending on your version, the MySQL server migit not support this */ if ($stmt->prepare('EXPLAIN SELECT t1.*, t2.* FROM test AS t1, test AS t2') && $stmt->execute()) { if (!mysqli_stmt_store_result($stmt)) printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!$res_meta = mysqli_stmt_result_metadata($stmt)) printf("[009] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (($tmp = mysqli_stmt_num_rows($stmt)) !== $num_rows) { printf("[010] Expecting int/%d got %s/%s\n", $num_rows, gettype($tmp), $tmp); } if (($tmp = mysqli_stmt_field_count($stmt)) !== $num_fields) { printf("[011] Expecting int/%d got %s/%s\n", $num_fields, gettype($tmp), $tmp); } if (($tmp = mysqli_field_count($link)) !== $num_fields) { printf("[013] Expecting int/%d got %s/%s\n", $num_fields, gettype($tmp), $tmp); } if (($tmp = $res_meta->field_count) !== $num_fields) { printf("[014] Expecting int/%d got %s/%s\n", $num_fields, gettype($tmp), $tmp); } $fields_res_meta = mysqli_fetch_fields($res_meta); if (($tmp = count($fields_res_meta)) !== $num_fields) printf("[015] Expecting int/%d got %s/%s\n", $num_fields, gettype($tmp), $tmp); if ($fields_res_meta != $fields) { printf("[016] Prepared Statement metadata differs from normal metadata, dumping\n"); var_dump($fields_res_meta); var_dump($fields); } if (function_exists('mysqli_stmt_get_result') && $stmt->prepare('EXPLAIN SELECT t1.*, t2.* FROM test AS t1, test AS t2') && $stmt->execute()) { if (!$res_stmt = mysqli_stmt_get_result($stmt)) { printf("[017] Cannot fetch result from PS [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); } if (($tmp = mysqli_num_rows($res_stmt)) !== $num_rows) { printf("[018] Expecting int/%d got %s/%s\n", $num_rows, gettype($tmp), $tmp); } if ((mysqli_stmt_num_rows($stmt)) !== 0) { printf("[019] Expecting int/0 got %s/%s\n", gettype($tmp), $tmp); } if (($tmp = mysqli_stmt_field_count($stmt)) !== $num_fields) { printf("[020] Expecting int/%d got %s/%s\n", $num_fields, gettype($tmp), $tmp); } if (($tmp = $res_stmt->field_count) !== $num_fields) { printf("[021] Expecting int/%d got %s/%s\n", $num_fields, gettype($tmp), $tmp); } $fields_stmt = mysqli_fetch_fields($res_stmt); if (($tmp = count($fields_stmt)) !== $num_fields) { printf("[022] Expecting int/%d got %s/%s\n", $num_fields, gettype($tmp), $tmp); } reset($fields); foreach ($fields_stmt as $fields_stmt_val) { list(,$fields_val) = each($fields); unset($fields_stmt_val->max_length); unset($fields_val->max_length); if ($fields_stmt_val != $fields_val) { printf("[023] PS mysqli_stmt_get_result() metadata seems wrong, dumping\n"); var_dump($fields_stmt_val); var_dump($fields_val); } } /* if ($fields_stmt != $fields) { printf("[023] PS mysqli_stmt_get_result() metadata seems wrong, dumping\n"); var_dump($fields_stmt); var_dump($fields); } */ mysqli_free_result($res_stmt); } } mysqli_stmt_close($stmt); mysqli_close($link); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_fetch_lengths.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_fetch_lengths.phpt +++ php-src/ext/mysqli/tests/mysqli_fetch_lengths.phpt --TEST-- mysqli_fetch_lengths() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) printf("[001] Cannot connect\n"); if (!is_null($tmp = @mysqli_fetch_lengths())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_fetch_lengths($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id LIMIT 1")) { printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } var_dump(mysqli_fetch_lengths($res)); while ($row = mysqli_fetch_assoc($res)) var_dump(mysqli_fetch_lengths($res)); var_dump(mysqli_fetch_lengths($res)); mysqli_free_result($res); var_dump(mysqli_fetch_lengths($res)); mysqli_close($link); print "done!"; ?> --EXPECTF-- bool(false) array(2) { [0]=> int(1) [1]=> int(1) } bool(false) Warning: mysqli_fetch_lengths(): Couldn't fetch mysqli_result in %s on line %d NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_fetch_lengths_oo.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_fetch_lengths_oo.phpt +++ php-src/ext/mysqli/tests/mysqli_fetch_lengths_oo.phpt --TEST-- mysqli_result->lengths --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) printf("[001] Cannot connect\n"); require('table.inc'); if (!$res = $mysqli->query("SELECT id, label FROM test ORDER BY id LIMIT 1")) { printf("[002] [%d] %s\n", $mysqli->errno, $mysqli->error); } var_dump($res->lengths); while ($row = $res->fetch_assoc()) var_dump($res->lengths); var_dump($res->lengths); $res->free_result(); var_dump($res->lengths); $mysqli->close(); print "done!"; ?> --EXPECTF-- NULL array(2) { [0]=> int(1) [1]=> int(1) } NULL Warning: main(): Couldn't fetch mysqli_result in %s on line %d NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_field_count.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_field_count.phpt +++ php-src/ext/mysqli/tests/mysqli_field_count.phpt --TEST-- mysqli_field_count() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_field_count())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_field_count($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); var_dump(mysqli_field_count($link)); if (!$res = mysqli_query($link, "SELECT * FROM test ORDER BY id LIMIT 1")) { printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } var_dump(mysqli_field_count($link)); mysqli_free_result($res); if (!mysqli_query($link, "INSERT INTO test(id, label) VALUES (100, 'x')")) printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump($link->field_count); var_dump(mysqli_field_count($link)); if (!$res = mysqli_query($link, 'SELECT NULL as _null, "" AS "", "three" AS "drei"')) printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump(mysqli_field_count($link)); mysqli_free_result($res); mysqli_close($link); var_dump(mysqli_field_count($link)); print "done!"; ?> --EXPECTF-- int(0) int(2) int(0) int(0) int(3) Warning: mysqli_field_count(): Couldn't fetch mysqli in %s on line %d NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_field_seek.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_field_seek.phpt +++ php-src/ext/mysqli/tests/mysqli_field_seek.phpt --TEST-- mysqli_field_seek() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php function mysqli_field_seek_flags($flags) { $ret = ''; if ($flags & MYSQLI_NOT_NULL_FLAG) $ret .= 'MYSQLI_NOT_NULL_FLAG '; if ($flags & MYSQLI_PRI_KEY_FLAG) $ret .= 'MYSQLI_PRI_KEY_FLAG '; if ($flags & MYSQLI_UNIQUE_KEY_FLAG) $ret .= 'MYSQLI_UNIQUE_KEY_FLAG '; if ($flags & MYSQLI_MULTIPLE_KEY_FLAG) $ret .= 'MYSQLI_MULTIPLE_KEY_FLAG '; if ($flags & MYSQLI_BLOB_FLAG) $ret .= 'MYSQLI_BLOB_FLAG '; if ($flags & MYSQLI_UNSIGNED_FLAG) $ret .= 'MYSQLI_UNSIGNED_FLAG '; if ($flags & MYSQLI_ZEROFILL_FLAG) $ret .= 'MYSQLI_ZEROFILL_FLAG '; if ($flags & MYSQLI_AUTO_INCREMENT_FLAG) $ret .= 'MYSQLI_AUTO_INCREMENT_FLAG '; if ($flags & MYSQLI_TIMESTAMP_FLAG) $ret .= 'MYSQLI_TIMESTAMP_FLAG '; if ($flags & MYSQLI_SET_FLAG) $ret .= 'MYSQLI_SET_FLAG '; if ($flags & MYSQLI_NUM_FLAG) $ret .= 'MYSQLI_NUM_FLAG '; if ($flags & MYSQLI_PART_KEY_FLAG) $ret .= 'MYSQLI_PART_KEY_FLAG '; if ($flags & MYSQLI_GROUP_FLAG) $ret .= 'MYSQLI_GROUP_FLAG '; return $ret; } include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_field_seek())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_field_seek($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id LIMIT 1", MYSQLI_USE_RESULT)) { printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } var_dump(mysqli_field_seek($res, -1)); var_dump(mysqli_fetch_field($res)); var_dump(mysqli_field_seek($res, 0)); var_dump(mysqli_fetch_field($res)); var_dump(mysqli_field_seek($res, 1)); var_dump(mysqli_fetch_field($res)); var_dump(mysqli_field_tell($res)); var_dump(mysqli_field_seek($res, 2)); var_dump(mysqli_fetch_field($res)); var_dump(mysqli_field_seek($res, PHP_INT_MAX + 1)); if (!is_null($tmp = @mysqli_field_seek($res, 0, "too many"))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_free_result($res); if (!$res = mysqli_query($link, "SELECT NULL as _null", MYSQLI_STORE_RESULT)) { printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } var_dump(mysqli_field_seek($res, 0)); var_dump(mysqli_fetch_field($res)); mysqli_free_result($res); var_dump(mysqli_field_seek($res, 0)); mysqli_close($link); print "done!"; ?> --EXPECTF-- Warning: mysqli_field_seek(): Invalid field offset in %s on line %d bool(false) object(stdClass)#%d (11) { ["name"]=> string(2) "id" ["orgname"]=> string(2) "id" ["table"]=> string(4) "test" ["orgtable"]=> string(4) "test" ["def"]=> string(0) "" ["max_length"]=> int(0) ["length"]=> int(11) ["charsetnr"]=> int(63) ["flags"]=> int(49155) ["type"]=> int(3) ["decimals"]=> int(0) } bool(true) object(stdClass)#%d (11) { ["name"]=> string(2) "id" ["orgname"]=> string(2) "id" ["table"]=> string(4) "test" ["orgtable"]=> string(4) "test" ["def"]=> string(0) "" ["max_length"]=> int(0) ["length"]=> int(11) ["charsetnr"]=> int(63) ["flags"]=> int(49155) ["type"]=> int(3) ["decimals"]=> int(0) } bool(true) object(stdClass)#%d (11) { ["name"]=> string(5) "label" ["orgname"]=> string(5) "label" ["table"]=> string(4) "test" ["orgtable"]=> string(4) "test" ["def"]=> string(0) "" ["max_length"]=> int(0) ["length"]=> int(1) ["charsetnr"]=> int(8) ["flags"]=> int(0) ["type"]=> int(254) ["decimals"]=> int(0) } int(2) Warning: mysqli_field_seek(): Invalid field offset in %s on line %d bool(false) bool(false) Warning: mysqli_field_seek(): Invalid field offset in %s on line %d bool(false) bool(true) object(stdClass)#3 (11) { ["name"]=> string(5) "_null" ["orgname"]=> string(0) "" ["table"]=> string(0) "" ["orgtable"]=> string(0) "" ["def"]=> string(0) "" ["max_length"]=> int(0) ["length"]=> int(0) ["charsetnr"]=> int(63) ["flags"]=> int(32896) ["type"]=> int(6) ["decimals"]=> int(0) } Warning: mysqli_field_seek(): Couldn't fetch mysqli_result in %s on line %d NULL done! --UEXPECTF-- Warning: mysqli_field_seek(): Invalid field offset in %s on line %d bool(false) object(stdClass)#%d (11) { [u"name"]=> unicode(2) "id" [u"orgname"]=> unicode(2) "id" [u"table"]=> unicode(4) "test" [u"orgtable"]=> unicode(4) "test" [u"def"]=> unicode(0) "" [u"max_length"]=> int(%d) [u"length"]=> int(%d) [u"charsetnr"]=> int(%d) [u"flags"]=> int(%d) [u"type"]=> int(%d) [u"decimals"]=> int(0) } bool(true) object(stdClass)#%d (11) { [u"name"]=> unicode(2) "id" [u"orgname"]=> unicode(2) "id" [u"table"]=> unicode(4) "test" [u"orgtable"]=> unicode(4) "test" [u"def"]=> unicode(0) "" [u"max_length"]=> int(%d) [u"length"]=> int(%d) [u"charsetnr"]=> int(%d) [u"flags"]=> int(%d) [u"type"]=> int(%d) [u"decimals"]=> int(0) } bool(true) object(stdClass)#%d (11) { [u"name"]=> unicode(5) "label" [u"orgname"]=> unicode(5) "label" [u"table"]=> unicode(4) "test" [u"orgtable"]=> unicode(4) "test" [u"def"]=> unicode(0) "" [u"max_length"]=> int(%d) [u"length"]=> int(%d) [u"charsetnr"]=> int(%d) [u"flags"]=> int(%d) [u"type"]=> int(%d) [u"decimals"]=> int(0) } int(2) Warning: mysqli_field_seek(): Invalid field offset in %s on line %d bool(false) bool(false) Warning: mysqli_field_seek(): Invalid field offset in %s on line %d bool(false) bool(true) object(stdClass)#3 (11) { [u"name"]=> unicode(5) "_null" [u"orgname"]=> unicode(0) "" [u"table"]=> unicode(0) "" [u"orgtable"]=> unicode(0) "" [u"def"]=> unicode(0) "" [u"max_length"]=> int(0) [u"length"]=> int(0) [u"charsetnr"]=> int(63) [u"flags"]=> int(32896) [u"type"]=> int(6) [u"decimals"]=> int(0) } Warning: mysqli_field_seek(): Couldn't fetch mysqli_result in %s on line %d NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_field_tell.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_field_tell.phpt +++ php-src/ext/mysqli/tests/mysqli_field_tell.phpt --TEST-- mysqli_field_tell() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_field_tell())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_field_tell($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysqli_query($link, "SELECT id FROM test ORDER BY id LIMIT 1", MYSQLI_USE_RESULT)) { printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } var_dump(mysqli_field_tell($res)); var_dump(mysqli_field_seek(1)); var_dump(mysqli_field_tell($res)); var_dump(mysqli_fetch_field($res)); var_dump(mysqli_fetch_field($res)); var_dump(mysqli_field_tell($res)); if (!is_null($tmp = @mysqli_field_tell($res, 'too many arguments'))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); var_dump(mysqli_field_seek($res, 2)); var_dump(mysqli_field_tell($res)); var_dump(mysqli_field_seek($res, -1)); var_dump(mysqli_field_tell($res)); var_dump(mysqli_field_seek($res, 0)); var_dump(mysqli_field_tell($res)); mysqli_free_result($res); var_dump(mysqli_field_tell($res)); mysqli_close($link); print "done!"; ?> --EXPECTF-- int(0) Warning: mysqli_field_seek() expects exactly 2 parameters, 1 given in %s on line %d NULL int(0) object(stdClass)#%d (11) { ["name"]=> string(2) "id" ["orgname"]=> string(2) "id" ["table"]=> string(4) "test" ["orgtable"]=> string(4) "test" ["def"]=> string(0) "" ["max_length"]=> int(0) ["length"]=> int(11) ["charsetnr"]=> int(63) ["flags"]=> int(49155) ["type"]=> int(3) ["decimals"]=> int(0) } bool(false) int(1) Warning: mysqli_field_seek(): Invalid field offset in %s on line %d bool(false) int(1) Warning: mysqli_field_seek(): Invalid field offset in %s on line %d bool(false) int(1) bool(true) int(0) Warning: mysqli_field_tell(): Couldn't fetch mysqli_result in %s on line %d NULL done! --UEXPECTF-- int(0) Warning: mysqli_field_seek() expects exactly 2 parameters, 1 given in %s on line %d NULL int(0) object(stdClass)#%d (11) { [u"name"]=> unicode(2) "id" [u"orgname"]=> unicode(2) "id" [u"table"]=> unicode(4) "test" [u"orgtable"]=> unicode(4) "test" [u"def"]=> unicode(0) "" [u"max_length"]=> int(%d) [u"length"]=> int(%d) [u"charsetnr"]=> int(%d) [u"flags"]=> int(%d) [u"type"]=> int(%d) [u"decimals"]=> int(0) } bool(false) int(1) Warning: mysqli_field_seek(): Invalid field offset in %s on line %d bool(false) int(1) Warning: mysqli_field_seek(): Invalid field offset in %s on line %d bool(false) int(1) bool(true) int(0) Warning: mysqli_field_tell(): Couldn't fetch mysqli_result in %s on line %d NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_free_result.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_free_result.phpt +++ php-src/ext/mysqli/tests/mysqli_free_result.phpt --TEST-- mysqli_free_result() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $db = 'test'; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_free_result())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_free_result($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysqli_query($link, "SELECT id FROM test ORDER BY id LIMIT 1")) { printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } print "a\n"; var_dump(mysqli_free_result($res)); print "b\n"; var_dump(mysqli_free_result($res)); if (!$res = mysqli_query($link, "SELECT id FROM test ORDER BY id LIMIT 1")) { printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } print "c\n"; var_dump($res = mysqli_store_result($link)); var_dump(mysqli_error($link)); print "[005]\n"; var_dump(mysqli_free_result($res)); if (!$res = mysqli_query($link, "SELECT id FROM test ORDER BY id LIMIT 1")) { printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } print "d\n"; var_dump($res = mysqli_use_result($link)); var_dump(mysqli_error($link)); print "[007]\n"; var_dump(mysqli_free_result($res)); mysqli_close($link); print "done!"; ?> --EXPECTF-- a NULL b Warning: mysqli_free_result(): Couldn't fetch mysqli_result in %s on line %d NULL c bool(false) %s(0) "" [005] Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, boolean given in %s on line %d NULL d bool(false) %s(0) "" [007] Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, boolean given in %s on line %d NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_charset.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_charset.phpt +++ php-src/ext/mysqli/tests/mysqli_get_charset.phpt --TEST-- mysqli_get_charset() --SKIPIF-- <?php require_once('skipifemb.inc'); require_once('skipif.inc'); if (!function_exists('mysqli_get_charset')) die("skip: function not available"); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_get_charset())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_get_charset($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_set_charset($link, $link))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysqli_query($link, 'SELECT version() AS server_version')) printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_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 = mysqli_query($link, 'SELECT @@character_set_connection AS charset, @@collation_connection AS collation')) printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); if (!($character_set_connection = $tmp['charset']) || !($collation_connection = $tmp['collation'])) printf("[008] Cannot determine current character set and collation\n"); if (!$res = mysqli_query($link, $sql = sprintf('SHOW CHARACTER SET LIKE "%s"', $character_set_connection))) printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); if (empty($tmp)) printf("[010] Cannot fetch Maxlen and/or Comment, test will fail: $sql\n"); $maxlen = (isset($tmp['Maxlen'])) ? $tmp['Maxlen'] : ''; $comment = (isset($tmp['Description'])) ? $tmp['Description'] : ''; if (!$res = mysqli_query($link, sprintf('SHOW COLLATION LIKE "%s"', $collation_connection))) printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); if (!($id = $tmp['Id'])) printf("[012] Cannot fetch Id/Number, test will fail\n"); if (!$res = mysqli_query($link, sprintf('SHOW VARIABLES LIKE "character_sets_dir"'))) printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); if (!($character_sets_dir = $tmp['Value'])) printf("[014] Cannot fetch character_sets_dir, test will fail\n"); if (!is_object($charset = mysqli_get_charset($link))) printf("[015] Expecting object/std_class, got %s/%s\n", gettype($charset), $charset); if (!isset($charset->charset) || !in_array(gettype($charset->charset), array("string", "unicode")) || ($character_set_connection !== $charset->charset)) printf("[016] Expecting string/%s, got %s/%s\n", $character_set_connection, gettype($charset->charset), $charset->charset); if (!isset($charset->collation) || !in_array(gettype($charset->collation), array("string", "unicode")) || ($collation_connection !== $charset->collation)) printf("[017] Expecting string/%s, got %s/%s\n", $collation_connection, gettype($charset->collation), $charset->collation); if (!isset($charset->dir) || !is_string($charset->dir)) printf("[019] Expecting string - ideally %s*, got %s/%s\n", $character_sets_dir, gettype($charset->dir), $charset->dir); if (!isset($charset->min_length) || !(is_int($charset->min_length)) || ($charset->min_length < 0) || ($charset->min_length > $charset->max_length)) printf("[020] Expecting int between 0 ... %d, got %s/%s\n", $charset->max_length, gettype($charset->min_length), $charset->min_length); if (!isset($charset->number) || !is_int($charset->number) || ($charset->number !== (int)$id)) printf("[021] Expecting int/%d, got %s/%s\n", $id, gettype($charset->number), $charset->number); if (!isset($charset->state) || !is_int($charset->state)) printf("[022] Expecting int/any, got %s/%s\n", gettype($charset->state), $charset->state); mysqli_close($link); if (NULL !== ($tmp = mysqli_get_charset($link))) printf("[023] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_get_charset(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_client_info.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_client_info.phpt +++ php-src/ext/mysqli/tests/mysqli_get_client_info.phpt --TEST-- mysqli_get_client_info() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; if (!is_string($info = mysqli_get_client_info()) || ('' === $info)) printf("[001] Expecting string/any_non_empty, got %s/%s\n", gettype($info), $info); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_client_version.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_client_version.phpt +++ php-src/ext/mysqli/tests/mysqli_get_client_version.phpt --TEST-- mysqli_get_client_version() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; if (!is_int($info = mysqli_get_client_version()) || ($info < 100)) printf("[001] Expecting int/any_non_empty, got %s/%s\n", gettype($info), $info); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_connection_stats.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_connection_stats.phpt +++ php-src/ext/mysqli/tests/mysqli_get_connection_stats.phpt --TEST-- mysqli_get_connection_stats() --SKIPIF-- <?PHP require_once('skipif.inc'); require_once('skipifemb.inc'); if (!function_exists('mysqli_get_connection_stats')) { die("skip only available with mysqlnd"); } ?> --FILE-- <?php $tmp = $link = null; if (!is_null($tmp = @mysqli_get_connection_stats())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_get_connection_stats($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); include "connect.inc"; include "table.inc"; if (!is_array($info = mysqli_get_connection_stats($link)) || empty($info)) printf("[003] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info); if (!is_array($info2 = mysqli_get_client_stats()) || empty($info2)) printf("[004] Expecting array/any_non_empty, got %s/%s\n", gettype($info2), $info2); if ($info !== $info2) { printf("[005] The hashes should be identical\n"); var_dump($info); var_dump($info2); } mysqli_close($link); include "table.inc"; if (!is_array($info = mysqli_get_connection_stats($link)) || empty($info)) printf("[006] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info); if (!is_array($info2 = mysqli_get_client_stats()) || empty($info2)) printf("[007] Expecting array/any_non_empty, got %s/%s\n", gettype($info2), $info2); // assuming the test is run in a plain-vanilla CLI environment if ($info === $info2) { printf("[008] The hashes should not be identical\n"); var_dump($info); var_dump($info2); } print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_host_info.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_host_info.phpt +++ php-src/ext/mysqli/tests/mysqli_get_host_info.phpt --TEST-- mysqli_get_host_info() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; if (!is_null($tmp = @mysqli_get_host_info())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_get_host_info(NULL))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require "table.inc"; if (!is_string($info = mysqli_get_host_info($link)) || ('' === $info)) printf("[003] Expecting string/any_non_empty, got %s/%s\n", gettype($info), $info); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_proto_info.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_proto_info.phpt +++ php-src/ext/mysqli/tests/mysqli_get_proto_info.phpt --TEST-- mysqli_get_proto_info() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; if (!is_null($tmp = @mysqli_get_proto_info())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_get_proto_info(NULL))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require "table.inc"; if (!is_int($info = mysqli_get_proto_info($link)) || ($info < 1)) printf("[003] Expecting int/any_non_empty, got %s/%s\n", gettype($info), $info); if (!is_null($tmp = @mysqli_get_proto_info('too many', 'arguments'))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_server_info.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_server_info.phpt +++ php-src/ext/mysqli/tests/mysqli_get_server_info.phpt --TEST-- mysqli_get_server_info() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; if (!is_null($tmp = @mysqli_get_server_info())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_get_server_info(NULL))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require "table.inc"; if (!is_string($info = mysqli_get_server_info($link)) || ('' === $info)) printf("[003] Expecting string/any_non_empty, got %s/%s\n", gettype($info), $info); if (!is_null($tmp = @mysqli_get_server_info('too', 'many arguments'))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_server_version.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_server_version.phpt +++ php-src/ext/mysqli/tests/mysqli_get_server_version.phpt --TEST-- mysqli_get_server_version() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; if (!is_null($tmp = @mysqli_get_server_version())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_get_server_version(NULL))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require "table.inc"; /* 5.1.5 -> 50105 -- major_version*10000 + minor_version *100 + sub_version */ /* < 30000 = pre 3.2.3, very unlikely! */ if (!is_int($info = mysqli_get_server_version($link)) || ($info < (3 * 10000))) printf("[003] Expecting int/any >= 30000, got %s/%s\n", gettype($info), $info); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_warnings.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_warnings.phpt +++ php-src/ext/mysqli/tests/mysqli_get_warnings.phpt --TEST-- mysqli_get_warnings() - TODO --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('connect.inc'); if (!$TEST_EXPERIMENTAL) die("skip - experimental (= unsupported) feature"); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_get_warnings())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_get_warnings($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_get_warnings(''))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { printf("[003] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); } if (false !== ($tmp = mysqli_get_warnings($link))) { printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), (is_object($tmp) ? var_dump($tmp, true) : $tmp)); } if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, "CREATE TABLE test (id SMALLINT)")) printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, "INSERT INTO test (id) VALUES (1000000)")) printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_object($warning = mysqli_get_warnings($link)) || 'mysqli_warning' != get_class($warning)) { printf("[008] Expecting object/mysqli_warning, got %s/%s\n", gettype($tmp), (is_object($tmp) ? var_dump($tmp, true) : $tmp)); } if (!method_exists($warning, 'next')) printf("[009] Borked object, method next is missing\n"); $properties = array_merge(get_object_vars($warning), get_class_vars(get_class($warning))); if (!empty($properties)) printf("[010] Properties have always been magic, hidden things - why are they visible now, a BC break...\n"); if ((!is_string($warning->message)) || ('' == $warning->message)) /* NULL or not there at all */ printf("[011] Expecting string/not empty, got %s/%s\n", gettype($warning->message), $warning->message); if ((!is_string($warning->sqlstate)) || ('' == $warning->sqlstate)) /* NULL or not there at all */ printf("[012] Expecting string/not empty, got %s/%s\n", gettype($warning->sqlstate), $warning->sqlstate); if ((!is_int($warning->errno)) || (0 == $warning->errno)) /* NULL or not there at all */ printf("[013] Expecting int/not 0, got %s/%s\n", gettype($warning->errno), $warning->errno); if (false !== ($tmp = $warning->next())) printf("[014] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, "INSERT INTO test (id) VALUES (1000000), (1000001)")) printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (($tmp = mysqli_warning_count($link)) !== 2) printf("[016] Expecting 2 warnings, got %d warnings", $tmp); if (!is_object($warning = mysqli_get_warnings($link)) || 'mysqli_warning' != get_class($warning)) { printf("[017] Expecting object/mysqli_warning, got %s/%s\n", gettype($tmp), (is_object($tmp) ? var_dump($tmp, true) : $tmp)); } if (true !== ($tmp = $warning->next())) printf("[018] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = $warning->next())) printf("[020] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) printf("[021] Cannot create mysqli object: [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); if (!$mysqli->query("DROP TABLE IF EXISTS t1")) printf("[022] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$mysqli->query("CREATE TABLE t1 (a smallint)")) printf("[023] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_object($warning = new mysqli_warning($mysqli))) printf("[024] Expecting object/mysqli_warning, got %s/%s", gettype($warning), $warning); if (!is_string($warning->message) || ('' == $warning->message)) printf("[025] Expecting string, got %s/%s", gettype($warning->message), $warning->message); if (!$mysqli->query("DROP TABLE t1")) printf("[026] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); /* Yes, I really want to check if the object property is empty */ if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) printf("[027] Cannot create mysqli object: [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); $warning = new mysqli_warning($mysqli); if (false !== ($tmp = $warning->next())) printf("[028] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if ('' != ($tmp = $warning->message)) printf("[029] Expecting string/empty, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) printf("[030] Cannot create mysqli object: [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); if (!$mysqli->query("DROP TABLE IF EXISTS t1")) printf("[031] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$mysqli->query("CREATE TABLE t1 (a smallint)")) printf("[032] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); /* out of range, three warnings */ if (!$mysqli->query("INSERT IGNORE INTO t1(a) VALUES (65536), (65536), (65536)")) printf("[033] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $warning = new mysqli_warning($mysqli); $i = 1; while ($warning->next() && ('' != ($tmp = $warning->message))) { if (ini_get('unicode.semantics') && !is_unicode($tmp)) printf("[033a] Warning should have been a unicode string, got %s/%s", gettype($tmp), $tmp); $i++; } if (3 != $i) printf("[034] Expecting three warnings, got %d warnings\n", $i); $stmt = mysqli_stmt_init(); $warning = new mysqli_warning($stmt); if (false !== ($tmp = $warning->next())) printf("[035] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_info.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_info.phpt +++ php-src/ext/mysqli/tests/mysqli_info.phpt --TEST-- mysqli_info() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; if (!is_null($tmp = @mysqli_info())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_info(NULL))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require "table.inc"; if (!$res = mysqli_query($link, 'INSERT INTO test(id, label) VALUES (100, "a")')) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); // NOTE: empty string, no multiple insert syntax if (!is_string($tmp = mysqli_info($link)) || ('' != $tmp)) printf("[004] Expecting string/empty, got %s/%s\n", gettype($tmp), $tmp); if (!$res = mysqli_query($link, 'INSERT INTO test(id, label) VALUES (101, "a"), (102, "b")')) printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_string($tmp = mysqli_info($link)) || ('' == $tmp)) printf("[006] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp); if (ini_get('unicode.semantics') && !is_unicode($tmp)) printf("[007] Expecting unicode, because unicode mode it on. Got binary string\n"); if (!$res = mysqli_query($link, 'INSERT INTO test(id, label) SELECT id + 200, label FROM test')) printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_string($tmp = mysqli_info($link)) || ('' == $tmp)) printf("[008] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp); if (!$res = mysqli_query($link, 'ALTER TABLE test MODIFY label CHAR(2)')) printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_string($tmp = mysqli_info($link)) || ('' == $tmp)) printf("[010] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp); if (!$res = mysqli_query($link, 'UPDATE test SET label = "b" WHERE id >= 100')) printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_string($tmp = mysqli_info($link)) || ('' == $tmp)) printf("[012] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp); if (!$res = mysqli_query($link, "SELECT 1")) printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_string($tmp = mysqli_info($link)) || ('' != $tmp)) printf("[014] Expecting string/empty, got %s/%s\n", gettype($tmp), $tmp); mysqli_free_result($res); // NOTE: no LOAD DATA INFILE test if ($dir = sys_get_temp_dir()) { do { $file = $dir . '/' . 'mysqli_info_phpt.cvs'; if (!$fp = fopen($file, 'w')) /* ignore this error */ break; if (!fwrite($fp, b"100;'a';\n") || !fwrite($fp, b"101;'b';\n") || !fwrite($fp, b"102;'c';\n")) { @unlink($file); break; } fclose($fp); if (!mysqli_query($link, "DELETE FROM test")) { printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); break; } if (!@mysqli_query($link, sprintf("LOAD DATA LOCAL INFILE '%s' INTO TABLE test FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '\'' LINES TERMINATED BY '\n'", $file))) { /* ok, because we might not be allowed to do this */ @unlink($file); break; } if (!is_string($tmp = mysqli_info($link)) || ('' == $tmp)) printf("[015] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp); unlink($file); } while (false); } print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_init.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_init.phpt +++ php-src/ext/mysqli/tests/mysqli_init.phpt --TEST-- mysqli_init() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php $link = mysqli_init(); if (!is_object($link) && false !== $link) printf("[001] Expecting object/mysqli_link or boolean/false, got %s/%s\n", gettype($link), $link); if (is_object($link) && 'mysqli' != get_class($link)) printf("[002] Expecting object of type mysqli got object of type %s\n", get_class($link)); if ($link) mysqli_close($link); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_insert_id.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_insert_id.phpt +++ php-src/ext/mysqli/tests/mysqli_insert_id.phpt --TEST-- mysqli_insert_id() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_insert_id())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_insert_id($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (0 !== ($tmp = mysqli_insert_id($link))) printf("[003] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); if (!$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id LIMIT 1")) { printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } if (0 !== ($tmp = mysqli_insert_id($link))) printf("[005] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); mysqli_free_result($res); // no auto_increment column if (!$res = mysqli_query($link, "INSERT INTO test(id, label) VALUES (100, 'a')")) { printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } if (0 !== ($tmp = mysqli_insert_id($link))) printf("[007] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); if (!$res = mysqli_query($link, "ALTER TABLE test MODIFY id INT NOT NULL AUTO_INCREMENT")) { printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } if (!$res = mysqli_query($link, "INSERT INTO test(label) VALUES ('a')")) { printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } if (($last_id = mysqli_insert_id($link)) <= 0) printf("[010] Expecting int/any >0, got %s/%s\n", gettype($last_id), $last_id); if (mysqli_query($link, "LOCK TABLE test WRITE")) { /* we need exclusive access for a moment */ /* let's hope nobody changes auto_increment_increment while this code executes */ do { if (mysqli_get_server_version($link) >= 50000) { if (!$res = mysqli_query($link, 'SELECT @@auto_increment_increment AS inc')) { printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); break; } if (!$row = mysqli_fetch_assoc($res)) { printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); break; } mysqli_free_result($res); $inc = $row['inc']; } else { $inc = 1; } if (!mysqli_query($link, "INSERT INTO test(label) VALUES ('b')")) { printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); break; } if (($next_id = mysqli_insert_id($link)) <= $last_id) /* very likely a bug, but someone could have done something on the server between the second last insert and the lock, therefore don't stop just bail */ printf("[014] Expecting int/any > %d, got %s/%s\n", $last_id, gettype($next_id), $next_id); $last_id = $next_id; if (!mysqli_query($link, "INSERT INTO test(label) VALUES ('c'), ('d'), ('e')")) { printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); break; } /* Note: For a multiple-row insert, LAST_INSERT_ID() and mysql_insert_id() actually return the AUTO_INCREMENT key from the first of the inserted rows. This allows multiple-row inserts to be reproduced correctly on other servers in a replication setup. */ if (($next_id = mysqli_insert_id($link)) != $last_id + $inc) { printf("[016] Expecting int/%d, got %s/%s\n", $last_id + 1, gettype($next_id), $next_id); break; } if (!$res = mysqli_query($link, "SELECT LAST_INSERT_ID() AS last_id")) { printf("[017] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); break; } if (!$row = mysqli_fetch_assoc($res)) { printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); break; } mysqli_free_result($res); if ($next_id != $row['last_id']) { printf("[018] Something is wrong, check manually. Expecting %s got %s.\n", $next_id, $row['last_id']); break; } } while (false); mysqli_query($link, "UNLOCK TABLE test"); } mysqli_close($link); var_dump(mysqli_insert_id($link)); print "done!"; ?> --EXPECTF-- Warning: mysqli_insert_id(): Couldn't fetch mysqli in %s on line %d NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_kill.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_kill.phpt +++ php-src/ext/mysqli/tests/mysqli_kill.phpt --TEST-- mysqli_kill() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_kill())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_kill($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); // Zend will cast the NULL to 0 if (!is_bool($tmp = mysqli_kill($link, null))) printf("[003] Expecting boolean/any, got %s/%s\n", gettype($tmp), $tmp); if (!$thread_id = mysqli_thread_id($link)) printf("[004] Cannot determine thread id, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_kill($link, $thread_id); if (!is_bool($tmp)) printf("[005] Expecting boolean/any, got %s/%s\n", gettype($tmp), $tmp); if ($res = mysqli_query($link, "SELECT id FROM test LIMIT 1")) pintf("[006] Expecting boolean/false, got %s/%s\n", gettype($res), $res); var_dump($error = mysqli_error($link)); if (!is_string($error) || ('' === $error)) printf("[007] Expecting string/any non empty, got %s/%s\n", gettype($error), $error); var_dump($res); var_dump($link); mysqli_close($link); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[008] Cannot connect, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); mysqli_kill($link, -1); if ((!$res = mysqli_query($link, "SELECT id FROM test LIMIT 1")) || (!$tmp = mysqli_fetch_assoc($res))) { printf("[009] Connection should not be gone, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } var_dump($tmp); mysqli_free_result($res); mysqli_close($link); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[010] Cannot connect, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); mysqli_change_user($link, "This might work if you accept anonymous users in your setup", "password", $db); mysqli_kill($link, -1); mysqli_close($link); print "done!"; ?> --EXPECTF-- Warning: mysqli_kill(): processid should have positive value in %s on line %d string(%d) "%s" bool(false) object(mysqli)#%d (0) { } Warning: mysqli_kill(): processid should have positive value in %s on line %d array(1) { ["id"]=> string(1) "1" } Warning: mysqli_kill(): processid should have positive value in %s on line %d done! --UEXPECTF-- Warning: mysqli_kill(): processid should have positive value in %s on line %d unicode(%d) "%s" bool(false) object(mysqli)#%d (0) { } Warning: mysqli_kill(): processid should have positive value in %s on line %d array(1) { [u"id"]=> unicode(1) "1" } Warning: mysqli_kill(): processid should have positive value in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_more_results.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_more_results.phpt +++ php-src/ext/mysqli/tests/mysqli_more_results.phpt --TEST-- mysqli_more_results() --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $strict_on = false; if (defined('E_STRICT')) { error_reporting(((int)ini_get('error_reporting')) | E_STRICT ); $strict_on = true; } $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_more_results())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_more_results($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); print "[004]\n"; var_dump(mysqli_more_results($link)); if (!mysqli_multi_query($link, "SELECT 1 AS a; SELECT 1 AS a, 2 AS b; SELECT id FROM test ORDER BY id LIMIT 3")) printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); print "[006]\n"; $i = 1; if ($strict_on) ob_start(); if (mysqli_get_server_version($link) > 41000 && !($ret = mysqli_more_results($link))) printf("[007] Expecting boolean/true, got %s/%s\n", gettype($ret), $ret); do { $res = mysqli_store_result($link); mysqli_free_result($res); if (mysqli_more_results($link)) printf("%d\n", $i++); } while (mysqli_next_result($link)); if ($strict_on) { $tmp = ob_get_contents(); ob_end_clean(); if (!preg_match('@Strict Standards: mysqli_next_result\(\): There is no next result set@ismU', $tmp)) { printf("[008] Strict Standards warning missing\n"); } else { $tmp = trim(preg_replace('@Strict Standards: mysqli_next_result\(\).*on line \d+@ism', '', $tmp)); } print trim($tmp) . "\n"; } if (!mysqli_multi_query($link, "SELECT 1 AS a; SELECT 1 AS a, 2 AS b; SELECT id FROM test ORDER BY id LIMIT 3")) printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); print "[010]\n"; $i = 1; if (mysqli_get_server_version($link) > 41000 && !($ret = mysqli_more_results($link))) printf("[011] Expecting boolean/true, got %s/%s\n", gettype($ret), $ret); if ($strict_on) ob_start(); do { $res = mysqli_use_result($link); // NOTE: if you use mysqli_use_result() with mysqli_more_results() or any other info function, // you must fetch all rows before you can loop to the next result set! // See also the MySQL Reference Manual: mysql_use_result() while ($row = mysqli_fetch_array($res)) ; mysqli_free_result($res); if (mysqli_more_results($link)) printf("%d\n", $i++); } while (mysqli_next_result($link)); if ($strict_on) { $tmp = ob_get_contents(); ob_end_clean(); if (!preg_match('@Strict Standards: mysqli_next_result\(\): There is no next result set@ismU', $tmp)) { printf("[008] Strict Standards warning missing\n"); } else { $tmp = trim(preg_replace('@Strict Standards: mysqli_next_result\(\).*on line \d+@ism', '', $tmp)); } print trim($tmp) . "\n"; } mysqli_close($link); var_dump(mysqli_more_results($link)); print "done!"; ?> --EXPECTF-- [004] bool(false) [006] 1 2 [010] 1 2 Warning: mysqli_more_results(): Couldn't fetch mysqli in %s on line %d NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_multi_query.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_multi_query.phpt +++ php-src/ext/mysqli/tests/mysqli_multi_query.phpt --TEST-- mysqli_multi_query() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $strict_on = false; if (defined('E_STRICT')) { error_reporting(((int)ini_get('error_reporting')) | E_STRICT ); $strict_on = true; } $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_multi_query())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_multi_query($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (false !== ($tmp = mysqli_multi_query($link, ""))) printf("[003] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_multi_query($link, "SELECT 1 AS a; SELECT 1 AS a, 2 AS b; SELECT id FROM test ORDER BY id LIMIT 3")) printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if ($strict_on) ob_start(); $i = 0; do { $res = mysqli_store_result($link); while ($row = mysqli_fetch_array($res)) ; mysqli_free_result($res); $i++; } while (mysqli_next_result($link)); if ($strict_on) { $tmp = ob_get_contents(); ob_end_clean(); if (!preg_match('@Strict Standards: mysqli_next_result\(\): There is no next result set@ismU', $tmp)) { printf("[005a] Strict Standards warning missing\n"); } else { $tmp = trim(preg_replace('@Strict Standards: mysqli_next_result\(\).*on line \d+@ism', '', $tmp)); } print trim($tmp) . "\n"; } printf("[006] %d\n", $i); if (!mysqli_multi_query($link, "ALTER TABLE test MODIFY id INT AUTO_INCREMENT; INSERT INTO test(label) VALUES ('a'); SELECT id, label FROM test ORDER BY id")) printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $i = 0; while (mysqli_next_result($link) && ($res = mysqli_store_result($link))) { while ($row = mysqli_fetch_array($res)) ; mysqli_free_result($res); printf("%d/%d\n", $i, mysqli_insert_id($link)); $i++; } printf("[008] %d\n", $i); if (!mysqli_multi_query($link, "SELECT id, label FROM test")) printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if ($strict_on) ob_start(); $i = 0; while (mysqli_next_result($link) && ($res = mysqli_store_result($link))) { while ($row = mysqli_fetch_array($res)) $i++; mysqli_free_result($res); } if ($strict_on) { $tmp = ob_get_contents(); ob_end_clean(); if (!preg_match('@Strict Standards: mysqli_next_result\(\): There is no next result set@ismU', $tmp)) { printf("[009a] Strict Standards warning missing\n"); } else { $tmp = trim(preg_replace('@Strict Standards: mysqli_next_result\(\).*on line \d+@ism', '', $tmp)); } print trim($tmp) . "\n"; } printf("[010] %d\n", $i); if (!mysqli_multi_query($link, "SELECT 1 AS num, 'a' AS somechar; SELECT 2 AS num, 'a' AS somechar; SELECT 3 AS num, 'a' AS somechar")) printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $res_num = 1; do { if (!$res = mysqli_store_result($link)) { printf("[012 - %d] [%d] %s\n", $res_num, mysqli_errno($link), mysqli_error($link)); continue; } $num_rows = 0; while ($row = mysqli_fetch_array($res)) { $num_rows++; if ($row['num'] != $res_num) printf("[013 - %d] Expecting %s got %s\n", $res_num, $res_num, $row['num']); if ($row['somechar'] != "a") printf("[014 - %d] Expecting a got %s\n", $res_num, $row['somechar']); if (1 == $num_rows) { /* simple metadata check */ if (!($lengths = mysqli_fetch_lengths($res))) printf("[015 - %d] [%d] %s\n", $res_num, mysqli_errno($link), mysqli_error($link)); if (count($lengths) != 2) printf("[016 - %d] Expecting 2 column lengths got %d [%d] %s\n", $res_num, count($lengths)); foreach ($lengths as $k => $length) if ($length <= 0) printf("[017 - %d] Strange column lengths for column %d, got %d expecting any > 0\n", $res_num, $k, $length); } } if ($num_rows != 1) printf("[018 - %d] Expecting 1 row, got %d rows\n", $num_rows); $res_num++; mysqli_free_result($res); } while (@mysqli_next_result($link)); if ($res_num != 4) printf("[015] Expecting 3 result sets got %d result set[s]\n", $res_num); mysqli_close($link); var_dump(mysqli_multi_query($link, "SELECT id, label FROM test")); print "done!"; ?> --EXPECTF-- [006] 3 [008] 0 [009] [2014] Commands out of sync; you can't run this command now [010] 7 Warning: mysqli_multi_query(): Couldn't fetch mysqli in %s on line %d NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_mysqli_result_invalid_mode.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_mysqli_result_invalid_mode.phpt +++ php-src/ext/mysqli/tests/mysqli_mysqli_result_invalid_mode.phpt --TEST-- mysqli_result(), invalid mode --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php require('connect.inc'); require('table.inc'); $valid = array(MYSQLI_STORE_RESULT, MYSQLI_USE_RESULT); do { $mode = mt_rand(-1000, 1000); } while (in_array($mode, $valid)); if (!is_object($res = new mysqli_result($link, $mode))) printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); print "done!"; ?> --EXPECTF-- Warning: mysqli_result::mysqli_result(): Invalid value for resultmode in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_next_result.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_next_result.phpt +++ php-src/ext/mysqli/tests/mysqli_next_result.phpt --TEST-- mysqli_next_result() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $strict_on = false; if (defined('E_STRICT')) { error_reporting(((int)ini_get('error_reporting')) | E_STRICT ); $strict_on = true; } $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_next_result())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_next_result($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if ($strict_on) ob_start(); if (false !== ($tmp = mysqli_next_result($link))) printf("[003] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if ($strict_on) { $tmp = ob_get_contents(); ob_end_clean(); if (!preg_match('@Strict Standards: mysqli_next_result\(\): There is no next result set@ismU', $tmp)) { printf("[003a] Strict Standards warning missing\n"); } else { $tmp = trim(preg_replace('@Strict Standards: mysqli_next_result\(\).*on line \d+@ism', '', $tmp)); } print trim($tmp) . "\n"; ob_start(); } $res = mysqli_query($link, "SELECT 1 AS res"); if (false !== ($tmp = mysqli_next_result($link))) printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if ($strict_on) { $tmp = ob_get_contents(); ob_end_clean(); if (!preg_match('@Strict Standards: mysqli_next_result\(\): There is no next result set@ismU', $tmp)) { printf("[004a] Strict Standards warning missing\n"); } else { $tmp = trim(preg_replace('@Strict Standards: mysqli_next_result\(\).*on line \d+@ism', '', $tmp)); } print trim($tmp) . "\n"; } mysqli_free_result($res); function func_test_mysqli_next_result($link, $query, $offset, $num_results, $strict_on) { if (!mysqli_multi_query($link, $query)) printf("[%03d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link)); $i = 0; if ($strict_on) ob_start(); do { if ($res = mysqli_store_result($link)) { mysqli_free_result($res); $i++; } } while (true === mysqli_next_result($link)); if ($strict_on) { $tmp = ob_get_contents(); ob_end_clean(); if (!preg_match('@Strict Standards: mysqli_next_result\(\): There is no next result set@ismU', $tmp)) { printf("[%03d] Strict Standards warning missing\n", $offset + 1); } else { $tmp = trim(preg_replace('@Strict Standards: mysqli_next_result\(\).*on line \d+@ism', '', $tmp)); } print trim($tmp) . "\n"; } if ($i !== $num_results) { printf("[%03d] Expecting %d result(s), got %d result(s)\n", $offset + 2, $num_results, $i); } if (mysqli_more_results($link)) printf("[%03d] mysqli_more_results() indicates more results than expected\n", $offset + 3); if (!($res = mysqli_query($link, "SELECT 1 AS b"))) { printf("[%03d] [%d] %s\n", $offset + 4, mysqli_errno($link), mysqli_error($link)); } else { mysqli_free_result($res); } } func_test_mysqli_next_result($link, "SELECT 1 AS a; SELECT 1 AS a, 2 AS b; SELECT id FROM test ORDER BY id LIMIT 3", 5, 3, $strict_on); func_test_mysqli_next_result($link, "SELECT 1 AS a; INSERT INTO test(id, label) VALUES (100, 'y'); SELECT 1 AS a, 2 AS b", 8, 2, $strict_on); func_test_mysqli_next_result($link, "DELETE FROM test WHERE id >= 100; SELECT 1 AS a; ", 11, 1, $strict_on); mysqli_close($link); var_dump(mysqli_next_result($link)); print "done!"; ?> --EXPECTF-- Warning: mysqli_next_result(): Couldn't fetch mysqli in %s on line %d NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_num_fields.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_num_fields.phpt +++ php-src/ext/mysqli/tests/mysqli_num_fields.phpt --TEST-- mysqli_num_fields() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_num_fields())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_num_fields($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); function func_test_mysqli_num_fields($link, $query, $expected, $offset, $test_free = false) { if (!($res = mysqli_query($link, $query))) { printf("[%03d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link)); return; } if ($expected !== ($tmp = mysqli_num_fields($res))) printf("[%03d] Expecting %s/%d, got %s/%d\n", $offset + 1, gettype($expected), $expected, gettype($tmp), $tmp); mysqli_free_result($res); if ($test_free && (NULL !== ($tmp = mysqli_num_fields($res)))) printf("[%03d] Expecting NULL, got %s/%s\n", $offset + 2, gettype($tmp), $tmp); } func_test_mysqli_num_fields($link, "SELECT 1 AS a", 1, 5); func_test_mysqli_num_fields($link, "SELECT id, label FROM test", 2, 10); func_test_mysqli_num_fields($link, "SELECT 1 AS a, NULL AS b, 'foo' AS c", 3, 15); func_test_mysqli_num_fields($link, "SELECT id FROM test", 1, 20, true); mysqli_close($link); print "done!"; ?> --EXPECTF-- Warning: mysqli_num_fields(): Couldn't fetch mysqli_result in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_num_rows.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_num_rows.phpt +++ php-src/ext/mysqli/tests/mysqli_num_rows.phpt --TEST-- mysqli_num_rows() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_num_rows())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_num_rows($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); function func_test_mysqli_num_rows($link, $query, $expected, $offset, $test_free = false) { if (!$res = mysqli_query($link, $query, MYSQLI_STORE_RESULT)) { printf("[%03d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link)); return; } if ($expected !== ($tmp = mysqli_num_rows($res))) printf("[%03d] Expecting %s/%d, got %s/%d\n", $offset + 1, gettype($expected), $expected, gettype($tmp), $tmp); mysqli_free_result($res); if ($test_free && (NULL !== ($tmp = mysqli_num_rows($res)))) printf("[%03d] Expecting NULL, got %s/%s\n", $offset + 2, gettype($tmp), $tmp); } func_test_mysqli_num_rows($link, "SELECT 1 AS a", 1, 5); func_test_mysqli_num_rows($link, "SHOW VARIABLES LIKE '%nixnutz%'", 0, 10); func_test_mysqli_num_rows($link, "INSERT INTO test(id, label) VALUES (100, 'z')", NULL, 15); func_test_mysqli_num_rows($link, "SELECT id FROM test LIMIT 2", 2, 20, true); if ($res = mysqli_query($link, 'SELECT COUNT(id) AS num FROM test')) { $row = mysqli_fetch_assoc($res); mysqli_free_result($res); func_test_mysqli_num_rows($link, "SELECT id, label FROM test", (int)$row['num'], 25); } else { printf("[030] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } print "run_tests.php don't fool me with your 'ungreedy' expression '.+?'!\n"; if ($res = mysqli_query($link, 'SELECT id FROM test', MYSQLI_USE_RESULT)) { $row = mysqli_fetch_row($res); if (0 !== ($tmp = mysqli_num_rows($res))) printf("[031] Expecting int/0, got %s/%d\n", gettype($tmp), $tmp); mysqli_free_result($res); } else { printf("[032] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } mysqli_close($link); print "done!"; ?> --EXPECTF-- Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in %s on line %d Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, boolean given in %s on line %d Warning: mysqli_num_rows(): Couldn't fetch mysqli_result in %s on line %d run_tests.php don't fool me with your 'ungreedy' expression '.+?'! Warning: mysqli_num_rows(): Function cannot be used with MYSQL_USE_RESULT in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_options.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_options.phpt +++ php-src/ext/mysqli/tests/mysqli_options.phpt --TEST-- mysqli_options() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $valid_options = array( MYSQLI_READ_DEFAULT_GROUP, MYSQLI_READ_DEFAULT_FILE, MYSQLI_OPT_CONNECT_TIMEOUT, MYSQLI_OPT_LOCAL_INFILE, MYSQLI_INIT_COMMAND, MYSQLI_READ_DEFAULT_GROUP, MYSQLI_READ_DEFAULT_FILE, MYSQLI_OPT_CONNECT_TIMEOUT, MYSQLI_OPT_LOCAL_INFILE, MYSQLI_INIT_COMMAND, MYSQLI_SET_CHARSET_NAME); if ($IS_MYSQLND && defined('MYSQLI_OPT_INT_AND_YEARS_AS_INT')) $valid_options[] = constant('MYSQLI_OPT_INT_AND_YEARS_AS_INT'); if (defined('MYSQLI_OPT_NUMERIC_AND_DATETIME_AS_UNICODE')) $valid_options[] = constant('MYSQLI_OPT_NUMERIC_AND_DATETIME_AS_UNICODE'); $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_options())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_options($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); $link = mysqli_init(); if (!is_null($tmp = @mysqli_options($link, MYSQLI_OPT_CONNECT_TIMEOUT))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_options($link, "s", 'extra_my.cnf'))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_options($link, MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT=0', 'foo'))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); // print "run_tests.php don't fool me with your 'ungreedy' expression '.+?'!\n"; var_dump("MYSQLI_READ_DEFAULT_GROUP", mysqli_options($link, MYSQLI_READ_DEFAULT_GROUP, 'extra_my.cnf')); var_dump("MYSQLI_READ_DEFAULT_FILE", mysqli_options($link, MYSQLI_READ_DEFAULT_FILE, 'extra_my.cnf')); var_dump("MYSQLI_OPT_CONNECT_TIMEOUT", mysqli_options($link, MYSQLI_OPT_CONNECT_TIMEOUT, 10)); var_dump("MYSQLI_OPT_LOCAL_INFILE", mysqli_options($link, MYSQLI_OPT_LOCAL_INFILE, 1)); var_dump("MYSQLI_INIT_COMMAND", mysqli_options($link, MYSQLI_INIT_COMMAND, array('SET AUTOCOMMIT=0', 'SET AUTOCOMMIT=1'))); var_dump("MYSQLI_READ_DEFAULT_GROUP", mysqli_options($link, MYSQLI_READ_DEFAULT_GROUP, 'extra_my.cnf')); var_dump("MYSQLI_READ_DEFAULT_FILE", mysqli_options($link, MYSQLI_READ_DEFAULT_FILE, 'extra_my.cnf')); var_dump("MYSQLI_OPT_CONNECT_TIMEOUT", mysqli_options($link, MYSQLI_OPT_CONNECT_TIMEOUT, 10)); var_dump("MYSQLI_OPT_LOCAL_INFILE", mysqli_options($link, MYSQLI_OPT_LOCAL_INFILE, 1)); var_dump("MYSQLI_INIT_COMMAND", mysqli_options($link, MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT=0')); var_dump("MYSQLI_CLIENT_SSL", mysqli_options($link, MYSQLI_CLIENT_SSL, 'not an mysqli_option')); if ($IS_MYSQLND && defined('MYSQLI_OPT_INT_AND_YEARS_AS_INT') && !($tmp = mysqli_options($link, constant('MYSQLI_OPT_INT_AND_YEARS_AS_INT'), true))) printf("[006] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp); if (defined('MYSQLI_OPT_NUMERIC_AND_DATETIME_AS_UNICODE') && !($tmp = mysqli_options($link, constant('MYSQLI_OPT_NUMERIC_AND_DATETIME_AS_UNICODE'), true))) printf("[006] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp); for ($flag = -10000; $flag < 10000; $flag++) { if (in_array($flag, $valid_options)) continue; if (FALSE !== ($tmp = mysqli_options($link, $flag, 'definetely not an mysqli_option'))) { var_dump("SOME_FLAG", $flag, $tmp); } } mysqli_close($link); echo "Link closed"; var_dump("MYSQLI_INIT_COMMAND", mysqli_options($link, MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT=1')); var_dump("SOME_RANDOM_FLAG", mysqli_options($link, $flag, 'definetly not an mysqli_option')); print "done!"; ?> --EXPECTF-- %s(25) "MYSQLI_READ_DEFAULT_GROUP" bool(true) %s(24) "MYSQLI_READ_DEFAULT_FILE" bool(true) %s(26) "MYSQLI_OPT_CONNECT_TIMEOUT" bool(true) %s(23) "MYSQLI_OPT_LOCAL_INFILE" bool(true) %s(19) "MYSQLI_INIT_COMMAND" bool(true) %s(25) "MYSQLI_READ_DEFAULT_GROUP" bool(true) %s(24) "MYSQLI_READ_DEFAULT_FILE" bool(true) %s(26) "MYSQLI_OPT_CONNECT_TIMEOUT" bool(true) %s(23) "MYSQLI_OPT_LOCAL_INFILE" bool(true) %s(19) "MYSQLI_INIT_COMMAND" bool(true) %s(17) "MYSQLI_CLIENT_SSL" bool(false) Link closed Warning: mysqli_options(): Couldn't fetch mysqli in %s line %d %s(19) "MYSQLI_INIT_COMMAND" NULL Warning: mysqli_options(): Couldn't fetch mysqli in %s line %d %s(16) "SOME_RANDOM_FLAG" NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_options_init_command.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_options_init_command.phpt +++ php-src/ext/mysqli/tests/mysqli_options_init_command.phpt --TEST-- mysqli_options() --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); die("skip - STUB - TODO - this is a stub to remind me that we should also actually test the options"); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php /* see mysqli.c for details */ include "connect.inc"; print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_pconnect.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_pconnect.phpt +++ php-src/ext/mysqli/tests/mysqli_pconnect.phpt --TEST-- mysqli_pconnect() --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); if (!stristr(mysqli_get_client_info(), 'mysqlnd')) die("skip: only available in mysqlnd"); ?> --FILE-- <?php include "connect.inc"; $host = 'p:' . $host; if (!$link = mysqli_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); mysqli_close($link); $num = 20; $connections = array(); for ($i = 0; $i < $num; $i++) { if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[003] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); $connections[] = $link; } while (count($connections)) { do { $index = mt_rand(0, $num); } while (!isset($connections[$index])); mysqli_close($connections[$index]); unset($connections[$index]); } $connections = array(); $num = 20; for ($i = 0; $i < $num; $i++) { if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[004] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); $connections[] = $link; } $left = $num; while (count($connections) && $left > 0) { do { $index = mt_rand(0, $num); } while (!isset($connections[$index]) && $left > 0); if (mt_rand(0, 1) > 0) { $left--; mysqli_close($connections[$index]); unset($connections[$index]); } else { $left--; if (!$connections[$index] = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[004] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); } flush(); } while (count($connections)) { do { $index = mt_rand(0, $num); } while (!isset($connections[$index])); mysqli_close($connections[$index]); unset($connections[$index]); } print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_phpinfo.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_phpinfo.phpt +++ php-src/ext/mysqli/tests/mysqli_phpinfo.phpt --TEST-- phpinfo() mysqli section --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include("connect.inc"); @ob_clean(); ob_start(); phpinfo(); $phpinfo = ob_get_contents(); ob_end_clean(); /* all versions should at least dump this minimum information */ if (!stristr($phpinfo, "mysqli support")) printf("[001] ext/mysqli should have exposed itself.\n"); if (!stristr($phpinfo, "client api library version")) printf("[002] ext/mysqli should have exposed the library version.\n"); if (!stristr($phpinfo, "mysqli.default_host")) printf("[003] php.ini setting mysqli.default_host not shown.\n"); if (!stristr($phpinfo, "mysqli.default_port")) printf("[004] php.ini setting mysqli.default_port not shown.\n"); if (!stristr($phpinfo, "mysqli.default_pw")) printf("[005] php.ini setting mysqli.default_pw not shown.\n"); if (!stristr($phpinfo, "mysqli.default_socket")) printf("[006] php.ini setting mysqli.default_socket not shown.\n"); if (!stristr($phpinfo, "mysqli.default_user")) printf("[007] php.ini setting mysqli.default_user not shown.\n"); if (!stristr($phpinfo, "mysqli.max_links")) printf("[008] php.ini setting mysqli.max_links not shown.\n"); if (!stristr($phpinfo, "mysqli.reconnect")) printf("[009] php.ini setting mysqli.reconnect not shown.\n"); if ($IS_MYSQLND) { $expected = array( 'client statistics', 'bytes_sent', 'bytes_received', 'packets_sent', 'packets_received', 'protocol_overhead_in', 'protocol_overhead_out', 'result_set_queries', 'non_result_set_queries', 'no_index_used', 'bad_index_used', 'buffered_sets', 'unbuffered_sets', 'ps_buffered_sets', 'ps_unbuffered_sets', 'flushed_normal_sets', 'flushed_ps_sets', 'rows_fetched_from_server', 'rows_fetched_from_client', 'rows_skipped', 'copy_on_write_saved', 'copy_on_write_performed', 'command_buffer_too_small', 'connect_success', 'connect_failure', 'connection_reused', 'explicit_close', 'implicit_close', 'disconnect_close', 'in_middle_of_command_close', 'explicit_free_result', 'implicit_free_result', 'explicit_stmt_close', 'implicit_stmt_close', 'put_hits', 'put_misses', 'get_hits', 'get_misses', 'size', 'free_items', 'references', 'mysqli.cache_size', 'mysql.allow_local_infile' ); foreach ($expected as $k => $entry) if (!stristr($phpinfo, $entry)) printf("[010] Could not find entry for '%s'\n", $entry); } print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_ping.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_ping.phpt +++ php-src/ext/mysqli/tests/mysqli_ping.phpt --TEST-- mysqli_ping() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_ping())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!is_null($tmp = @mysqli_ping($link, $link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); var_dump(mysqli_ping($link)); // provoke an error to check if mysqli_ping resets it $res = mysqli_query($link, 'SELECT * FROM unknown_table'); if (!($errno = mysqli_errno($link))) printf("[003] Statement should have caused an error\n"); var_dump(mysqli_ping($link)); if ($errno === mysqli_errno($link)) printf("[004] Error codes should have been reset\n"); mysqli_close($link); if (!is_null($tmp = mysqli_ping($link))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- bool(true) bool(true) Warning: mysqli_ping(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_prepare.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_prepare.phpt +++ php-src/ext/mysqli/tests/mysqli_prepare.phpt --TEST-- mysqli_prepare() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_prepare())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_prepare($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (false !== ($tmp = @mysqli_prepare($link, false))) printf("[003] Expecting boolean/false, got %s\n", gettype($tmp)); if (!$res = mysqli_query($link, "SELECT id, label FROM test", MYSQLI_USE_RESULT)) printf("[004] [%d] %s, next test will fail\n", mysqli_errno($link), mysqli_error($link)); if (false !== ($tmp = mysqli_prepare($link, 'SELECT id FROM test WHERE id > ?'))) printf("[005] Expecting boolean/false, got %s, [%d] %s\n", gettype($tmp), mysqli_errno($link), mysqli_error($link)); mysqli_free_result($res); if (!is_object(($stmt = mysqli_prepare($link, 'SELECT id FROM test'))) || !mysqli_stmt_execute($stmt)) printf("[006][%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_stmt_close($stmt); if (!mysqli_query($link, "DROP TABLE IF EXISTS test2")) printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_object(($stmt = mysqli_prepare($link, 'CREATE TABLE test2(id INT) ENGINE =' . $engine))) || !mysqli_stmt_execute($stmt)) printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_stmt_close($stmt); if (!is_object(($stmt = mysqli_prepare($link, 'INSERT INTO test2(id) VALUES(?)')))) printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $id = 1; if (!mysqli_bind_param($stmt, 'i', $id) || !mysqli_stmt_execute($stmt)) printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_stmt_close($stmt); if (!is_object(($stmt = mysqli_prepare($link, 'REPLACE INTO test2(id) VALUES (?)')))) printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $id = 2; if (!mysqli_bind_param($stmt, 'i', $id) || !mysqli_stmt_execute($stmt)) printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_stmt_close($stmt); if (!is_object(($stmt = mysqli_prepare($link, 'UPDATE test2 SET id = ? WHERE id = ?')))) printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $id = 3; $where = 2; if (!mysqli_bind_param($stmt, 'ii', $id, $where) || !mysqli_stmt_execute($stmt)) printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_stmt_close($stmt); if (!is_object(($stmt = mysqli_prepare($link, 'DELETE FROM test2 WHERE id = ?')))) printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $where = 3; if (!mysqli_bind_param($stmt, 'i', $where) || !mysqli_stmt_execute($stmt)) printf("[016] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_stmt_close($stmt); if (!is_object(($stmt = mysqli_prepare($link, 'SET @testvar = ?')))) printf("[017] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $testvar = 'testvar'; if (!mysqli_bind_param($stmt, 's', $testvar) || !mysqli_stmt_execute($stmt)) printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_stmt_close($stmt); if (!is_object(($stmt = mysqli_prepare($link, 'DO GET_LOCK("testlock", 1)')))) printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_stmt_close($stmt); if (!is_object(($stmt = mysqli_prepare($link, 'SELECT id, @testvar FROM test2')))) printf("[020] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $id = $testvar = null; if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_bind_result($stmt, $id, $testvar)) printf("[021] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); while (mysqli_stmt_fetch($stmt)) { if (('testvar' !== $testvar) || (1 !== $id)) printf("[022] Expecting 'testvar'/1, got %s/%s. [%d] %s\n", $testvar, $id, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); } var_dump(mysqli_stmt_prepare($stmt, 'SELECT 1; SELECT 2')); mysqli_stmt_close($stmt); if (!is_null($tmp = @mysqli_stmt_prepare($link, 'SELECT id FROM test', 'foo'))) printf("[023] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); if (!is_null($tmp = @mysqli_stmt_prepare($link, 'SELECT id FROM test'))) printf("[024] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- bool(false) done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_prepare_no_object.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_prepare_no_object.phpt +++ php-src/ext/mysqli/tests/mysqli_prepare_no_object.phpt --TEST-- mysqli_prepare() - no object on failure --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; require('table.inc'); if (false !== ($tmp = mysqli_prepare($link, false))) printf("[001] Expecting boolean/false, got %s/%s\n", gettype($tmp), (is_object($tmp) ? var_dump($tmp, true) : $tmp)); printf("a) [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (false !== ($tmp = mysqli_prepare($link, ''))) printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), (is_object($tmp) ? var_dump($tmp, true) : $tmp)); printf("b) [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_close($link); if (!$mysqli = new mysqli($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); if (false !== ($tmp = $mysqli->prepare(false))) printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), (is_object($tmp) ? var_dump($tmp, true) : $tmp)); printf("c) [%d] %s\n", $mysqli->errno, $mysqli->error); if (false !== ($tmp = $mysqli->prepare(''))) printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), (is_object($tmp) ? var_dump($tmp, true) : $tmp)); printf("c) [%d] %s\n", $mysqli->errno, $mysqli->error); print "done!"; ?> --EXPECTF-- a) [1065] Query was empty b) [1065] Query was empty c) [1065] Query was empty c) [1065] Query was empty done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_query.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_query.phpt +++ php-src/ext/mysqli/tests/mysqli_query.phpt --TEST-- mysqli_query() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_query())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_query($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (false !== ($tmp = @mysqli_query($link, ''))) printf("[002a] Expecting boolean/false got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_query($link, "SELECT 1 AS a", MYSQLI_USE_RESULT, "foo"))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysqli_query($link, 'THIS IS NOT SQL'))) printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysqli_query($link, 'SELECT "this is sql but with backslash g"\g'))) printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if ((0 === mysqli_errno($link)) || ('' == mysqli_error($link))) printf("[006] mysqli_errno()/mysqli_error should return some error\n"); if (!$res = mysqli_query($link, 'SELECT "this is sql but with semicolon" AS valid ; ')) printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump(mysqli_fetch_assoc($res)); mysqli_free_result($res); if (!$res = mysqli_query($link, 'SELECT "a" AS ""')) printf("[007a] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump($tmp = mysqli_fetch_assoc($res)); var_dump($tmp[""]); mysqli_free_result($res); if (false !== ($res = mysqli_query($link, 'SELECT "this is sql but with semicolon" AS valid ; SHOW VARIABLES'))) printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (mysqli_get_server_version($link) > 50000) { // let's try to play with stored procedures mysqli_query($link, 'DROP PROCEDURE IF EXISTS p'); if (mysqli_query($link, 'CREATE PROCEDURE p(OUT ver_param VARCHAR(25)) BEGIN SELECT VERSION() INTO ver_param; END;')) { $res = mysqli_query($link, 'CALL p(@version)'); $res = mysqli_query($link, 'SELECT @version AS p_version'); $tmp = mysqli_fetch_assoc($res); if (!is_array($tmp) || empty($tmp) || !isset($tmp['p_version']) || ('' == $tmp['p_version'])) { printf("[008a] Expecting array [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump($tmp); } mysqli_free_result($res); } else { printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } mysqli_query($link, 'DROP FUNCTION IF EXISTS f'); if (mysqli_query($link, 'CREATE FUNCTION f( ver_param VARCHAR(25)) RETURNS VARCHAR(25) DETERMINISTIC RETURN ver_param;')) { $res = mysqli_query($link, 'SELECT f(VERSION()) AS f_version'); $tmp = mysqli_fetch_assoc($res); if (!is_array($tmp) || empty($tmp) || !isset($tmp['f_version']) || ('' == $tmp['f_version'])) { printf("[009a] Expecting array [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump($tmp); } mysqli_free_result($res); } else { printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } } if (!is_object($res = mysqli_query($link, "SELECT id FROM test ORDER BY id", MYSQLI_USE_RESULT))) printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_free_result($res); if (!is_object($res = mysqli_query($link, "SELECT id FROM test ORDER BY id", MYSQLI_STORE_RESULT))) printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_free_result($res); $valid = array(MYSQLI_USE_RESULT, MYSQLI_STORE_RESULT); do { $mode = mt_rand(-1000, 1000); } while (in_array($mode, $valid)); if (false !== ($res = @mysqli_query($link, "SELECT id FROM test ORDER BY id", $mode))) printf("[013] Invalid mode should return false got %s/%s, [%d] %s\n", gettype($res), (is_object($res)) ? 'object' : $res, mysqli_errno($link), mysqli_error($link)); mysqli_close($link); if (NULL !== ($tmp = mysqli_query($link, "SELECT id FROM test"))) printf("[011] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- array(1) { ["valid"]=> string(30) "this is sql but with semicolon" } array(1) { [""]=> string(1) "a" } string(1) "a" Warning: mysqli_query(): Couldn't fetch mysqli in %s on line %d done! --UEXPECTF-- array(1) { [u"valid"]=> unicode(30) "this is sql but with semicolon" } array(1) { [u""]=> unicode(1) "a" } unicode(1) "a" Warning: mysqli_query(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_query_unicode.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_query_unicode.phpt +++ php-src/ext/mysqli/tests/mysqli_query_unicode.phpt --TEST-- mysqli_query() - unicode (cyrillic) --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('connect.inc'); require_once('table.inc'); if (!$res = mysqli_query($link, "SHOW CHARACTER SET LIKE 'utf8'")) die("skip UTF8 chatset seems not available"); mysqli_free_result($res); mysqli_close($link); ?> --FILE-- <?php include_once("connect.inc"); $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_query())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_query($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require_once('table.inc'); if (TRUE !== ($tmp = @mysqli_query($link, "set names utf8"))) printf("[002.5] Expecting TRUE, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_query($link, "SELECT 1 AS колона", MYSQLI_USE_RESULT, "foo"))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysqli_query($link, 'Ñова не е еÑкÑел'))) printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysqli_query($link, 'SELECT "Ñова е еÑкÑел, но ÑÑÑ Ð¾Ð±ÑаÑна наклонена и g"\g'))) printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if ((0 === mysqli_errno($link)) || ('' == mysqli_error($link))) printf("[006] mysqli_errno()/mysqli_error should return some error\n"); if (!$res = mysqli_query($link, 'SELECT "Ñова еÑкÑел, но Ñ ÑоÑка и запеÑаÑ" AS пÑавилен ; ')) printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump(mysqli_fetch_assoc($res)); mysqli_free_result($res); if (false !== ($res = mysqli_query($link, 'SELECT "Ñова еÑкÑел, но Ñ ÑоÑка и запеÑаÑ" AS пÑавилен ; SHOW VARIABLES'))) printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (mysqli_get_server_version($link) > 50000) { // let's try to play with stored procedures mysqli_query($link, 'DROP PROCEDURE IF EXISTS пÑоÑедÑÑка'); if (mysqli_query($link, 'CREATE PROCEDURE пÑоÑедÑÑка(OUT веÑÑÐ¸Ñ VARCHAR(25)) BEGIN SELECT VERSION() INTO веÑÑиÑ; END;')) { $res = mysqli_query($link, 'CALL пÑоÑедÑÑка(@version)'); $res = mysqli_query($link, 'SELECT @version AS п_веÑÑиÑ'); $tmp = mysqli_fetch_assoc($res); if (!is_array($tmp) || empty($tmp) || !isset($tmp['п_веÑÑиÑ']) || ('' == $tmp['п_веÑÑиÑ'])) { printf("[008a] Expecting array [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump($tmp); } mysqli_free_result($res); } else { printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } mysqli_query($link, 'DROP FUNCTION IF EXISTS ÑÑнкÑийка'); if (mysqli_query($link, 'CREATE FUNCTION ÑÑнкÑийка( паÑамеÑÑÑ_веÑÑÐ¸Ñ VARCHAR(25)) RETURNS VARCHAR(25) DETERMINISTIC RETURN паÑамеÑÑÑ_веÑÑиÑ;')) { $res = mysqli_query($link, 'SELECT ÑÑнкÑийка(VERSION()) AS Ñ_веÑÑиÑ'); $tmp = mysqli_fetch_assoc($res); if (!is_array($tmp) || empty($tmp) || !isset($tmp['Ñ_веÑÑиÑ']) || ('' == $tmp['Ñ_веÑÑиÑ'])) { printf("[009a] Expecting array [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump($tmp); } mysqli_free_result($res); } else { printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } } /* Trying to test what Ramil suggests in http://bugs.mysql.com/bug.php?id=29576 However, this won't work, because we're lacking MYSQLI_SET_CHARSET_NAME. if (ini_get("unicode.semantics")) { if (mysqli_get_server_version() > 50002) { @mysqli_query($link, "DROP USER IF EXISTS 'ÑеÑÑ'@'%'"); if (TRUE !== mysqli_query($link, "CREATE USER 'ÑеÑÑ'@'%'")) { var_dump(mysqli_error($link); } } if (TRUE !== mysqli_query($link, "GRANT SELECT ON $db.* TO 'ÑеÑÑ'@'%' IDENTIFIED BY 'паÑола'")) { var_dump(mysqli_error($link); } else { $link2 = mysqli_init(); if (!(mysqli_real_connect($link2, $host, "ÑеÑÑ", 'паÑола', $db, $port, $socket))) { printf("[011] Cannot connect to the server using host=%s, user=%s, passwd=паÑола, dbname=%s, port=%s, socket=%s, [%d] %s\n", $host, "ÑеÑÑ", $db, $port, $socket, mysqli_connect_errno(), mysqli_connect_error()); } mysqli_close($link2); if (mysqli_get_server_version() > 50002) { if (!mysqli_query($link, "DROP USER 'ÑеÑÑ'@'%'")) printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } else { printf("[015] Cannot create user or grant privileges, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } } } } */ mysqli_close($link); if (NULL !== ($tmp = mysqli_query($link, "SELECT id FROM test"))) printf("[014] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- array(1) { ["пÑавилен"]=> string(59) "Ñова еÑкÑел, но Ñ ÑоÑка и запеÑаÑ" } Warning: mysqli_query(): Couldn't fetch mysqli in %s on line %d done! --UEXPECTF-- array(1) { [u"пÑавилен"]=> unicode(33) "Ñова еÑкÑел, но Ñ ÑоÑка и запеÑаÑ" } Warning: mysqli_query(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_real_escape_string.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_real_escape_string.phpt +++ php-src/ext/mysqli/tests/mysqli_real_escape_string.phpt --TEST-- mysqli_real_escape_string() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (NULL !== ($tmp = @mysqli_real_escape_string())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_real_escape_string($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (NULL !== ($tmp =@mysqli_real_escape_string($link, "foo", "foo"))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if ('\\\\' !== ($tmp = mysqli_real_escape_string($link, '\\'))) printf("[004] Expecting \\\\, got %s\n", $tmp); if ('\"' !== ($tmp = mysqli_real_escape_string($link, '"'))) printf("[005] Expecting \", got %s\n", $tmp); if ("\'" !== ($tmp = mysqli_real_escape_string($link, "'"))) printf("[006] Expecting ', got %s\n", $tmp); if ("\\n" !== ($tmp = mysqli_real_escape_string($link, "\n"))) printf("[007] Expecting \\n, got %s\n", $tmp); if ("\\r" !== ($tmp = mysqli_real_escape_string($link, "\r"))) printf("[008] Expecting \\r, got %s\n", $tmp); if ("foo\\0bar" !== ($tmp = mysqli_real_escape_string($link, "foo" . chr(0) . "bar"))) printf("[009] Expecting %s, got %s\n", "foo\\0bar", $tmp); mysqli_close($link); if (NULL !== ($tmp = mysqli_real_escape_string($link, 'foo'))) printf("[010] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); /* Make sure that the function alias exists */ if (NULL !== ($tmp = @mysqli_escape_string())) printf("[011] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_real_escape_string(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_real_escape_string_unicode.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_real_escape_string_unicode.phpt +++ php-src/ext/mysqli/tests/mysqli_real_escape_string_unicode.phpt --TEST-- mysqli_real_escape_string() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (NULL !== ($tmp = @mysqli_real_escape_string())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_real_escape_string($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (NULL !== ($tmp =@mysqli_real_escape_string($link, "ÑÑÑ", "баÑ"))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if ('ÑÑ\\\\баÑ' !== ($tmp = mysqli_real_escape_string($link, 'ÑÑ\\баÑ'))) printf("[004] Expecting ÑÑ\\\\баÑ, got %s\n", $tmp); if ('баÑ\"ÑÑÑ' !== ($tmp = mysqli_real_escape_string($link, 'баÑ"ÑÑÑ'))) printf("[005] Expecting баÑ\"ÑÑÑ, got %s\n", $tmp); if ("лала\'лали" !== ($tmp = mysqli_real_escape_string($link, "лала'лали"))) printf("[006] Expecting лала'лали, got %s\n", $tmp); if ("абÑа\\nкадабÑа" !== ($tmp = mysqli_real_escape_string($link, "абÑа\nкадабÑа"))) printf("[007] Expecting абÑа\\nкадабÑа, got %s\n", $tmp); if ("манда\\rин" !== ($tmp = mysqli_real_escape_string($link, "манда\rин"))) printf("[008] Expecting \\r, got %s\n", $tmp); if ("Ð¸Ñ Ñ\\0Ð°Ñ Ñ" !== ($tmp = mysqli_real_escape_string($link, "Ð¸Ñ Ñ" . chr(0) . "Ð°Ñ Ñ"))) printf("[009] Expecting %s, got %s\n", "Ð¸Ñ Ñ\\0Ð°Ñ Ñ", $tmp); if (($exp='абÑа\\\\ка\"да\\'."'".'бÑа\ZÑим\\nÑала\\rби\\0м') !== ($tmp = mysqli_real_escape_string($link, "абÑа\\ка\"да'бÑа\032Ñим\nÑала\rби" . chr(0) . "м"))) { printf("[010] Expecting %s, got %s\n", $exp, $tmp, var_dump($exp, $tmp)); } if ('å¯\\\\é å§' !== ($tmp = mysqli_real_escape_string($link, 'å¯\\é å§'))) printf("[011] Expecting å¯\\\\é å§, got %s\n", $tmp); if ('é å§\"å°é¢å¤§å' !== ($tmp = mysqli_real_escape_string($link, 'é å§"å°é¢å¤§å'))) printf("[012] Expecting é å§\"å°é¢å¤§å, got %s\n", $tmp); if ("ææ\'西é å¾" !== ($tmp = mysqli_real_escape_string($link, "ææ'西é å¾"))) printf("[013] Expecting ææ'西é å¾, got %s\n", $tmp); if ("é¿åæ\\nè½»" !== ($tmp = mysqli_real_escape_string($link, "é¿åæ\nè½»"))) printf("[014] Expecting é¿åæ\\nè½», got %s\n", $tmp); if ("å¼ æå®\\rå¨" !== ($tmp = mysqli_real_escape_string($link, "å¼ æå®\rå¨"))) printf("[015] Expecting å¼ æå®\\rå¨, got %s\n", $tmp); if ("ç«ºå¯æ¡¢\\0空è°å¨" !== ($tmp = mysqli_real_escape_string($link, "ç«ºå¯æ¡¢" . chr(0) . "空è°å¨"))) printf("[016] Expecting %s, got %s\n", "ç«ºå¯æ¡¢\\0空è°å¨", $tmp); if (($exp='é¿åæ\\\\å\"达丰\\'."'".'乳罩\Zè¾\\nè¨æ\\ræ¯\\0ç±³') !== ($tmp = mysqli_real_escape_string($link, "é¿åæ\\å\"达丰'乳罩\032è¾\nè¨æ\ræ¯" . chr(0) . "ç±³"))) { printf("[017] Expecting %s, got %s\n", $exp, $tmp, var_dump($exp, $tmp)); } mysqli_close($link); if (NULL !== ($tmp = mysqli_real_escape_string($link, 'foo'))) printf("[018] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_real_escape_string(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_real_query.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_real_query.phpt +++ php-src/ext/mysqli/tests/mysqli_real_query.phpt --TEST-- mysqli_real_query() --SKIPIF-- <?php require_once('skipif.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_real_query())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_real_query($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (NULL !== ($tmp = @mysqli_real_query($link, "SELECT 1 AS a", MYSQLI_USE_RESULT, "foo"))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysqli_real_query($link, 'THIS IS NOT SQL'))) printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysqli_real_query($link, 'SELECT "this is sql but with backslash g"\g'))) printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if ((0 === mysqli_errno($link)) || ('' == mysqli_error($link))) printf("[006] mysqli_errno()/mysqli_error should return some error\n"); if (!mysqli_real_query($link, 'SELECT "this is sql but with semicolon" AS valid ; ')) printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_object($res = mysqli_use_result($link))) printf("[008] Expecting reseult object, got %s/%s [%d] %s\n", gettype($res), $res, mysqli_errno($link), mysqli_error($link)); var_dump(mysqli_fetch_assoc($res)); mysqli_free_result($res); if (false !== ($res = mysqli_real_query($link, 'SELECT "this is sql but with semicolon" AS valid ; SHOW VARIABLES'))) printf("[008] Expecting boolean/false, got %s/%s, [%d] %s\n", gettype($res), $res, mysqli_errno($link), mysqli_error($link)); if (mysqli_get_server_version($link) > 50000) { // let's try to play with stored procedures mysqli_real_query($link, 'DROP PROCEDURE IF EXISTS p'); if (mysqli_real_query($link, 'CREATE PROCEDURE p(OUT ver_param VARCHAR(25)) BEGIN SELECT VERSION() INTO ver_param; END;')) { mysqli_real_query($link, 'CALL p(@version)'); mysqli_real_query($link, 'SELECT @version AS p_version'); $res = mysqli_store_result($link); $tmp = mysqli_fetch_assoc($res); if (!is_array($tmp) || empty($tmp) || !isset($tmp['p_version']) || ('' == $tmp['p_version'])) { printf("[008a] Expecting array [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump($tmp); } mysqli_free_result($res); } else { printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } mysqli_real_query($link, 'DROP FUNCTION IF EXISTS f'); if (mysqli_real_query($link, 'CREATE FUNCTION f( ver_param VARCHAR(25)) RETURNS VARCHAR(25) DETERMINISTIC RETURN ver_param;')) { mysqli_real_query($link, 'SELECT f(VERSION()) AS f_version'); $res = mysqli_store_result($link); $tmp = mysqli_fetch_assoc($res); if (!is_array($tmp) || empty($tmp) || !isset($tmp['f_version']) || ('' == $tmp['f_version'])) { printf("[009a] Expecting array [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump($tmp); } mysqli_free_result($res); } else { printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } } mysqli_close($link); if (NULL !== ($tmp = mysqli_real_query($link, "SELECT id FROM test"))) printf("[011] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- array(1) { ["valid"]=> string(30) "this is sql but with semicolon" } Warning: mysqli_real_query(): Couldn't fetch mysqli in %s on line %d done! --UEXPECTF-- array(1) { [u"valid"]=> unicode(30) "this is sql but with semicolon" } Warning: mysqli_real_query(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_report.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_report.phpt +++ php-src/ext/mysqli/tests/mysqli_report.phpt --TEST-- mysqli_report() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (NULL !== ($tmp = @mysqli_report())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = mysqli_report(-1))) printf("[002] Expecting boolean/true even for invalid flags, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_ERROR))) printf("[003] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_STRICT))) printf("[004] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_INDEX))) printf("[005] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_ALL))) printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_OFF))) printf("[008] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); /* Internal macro MYSQL_REPORT_ERROR */ mysqli_report(MYSQLI_REPORT_ERROR); mysqli_multi_query($link, "BAR; FOO;"); mysqli_query($link, "FOO"); /* This might work if you accept anonymous users in your setup */ mysqli_change_user($link, "0123456789-10-456789-20-456789-30-456789-40-456789-50-456789-60-456789-70-456789-80-456789-90-456789", "password", $db); mysqli_kill($link, -1); // mysqli_ping() cannot be tested, because one would need to cause an error inside the C function to test it mysqli_prepare($link, "FOO"); mysqli_real_query($link, "FOO"); if (@mysqli_select_db($link, "Oh lord, let this be an unknown database name")) printf("[009] select_db should have failed\n"); // mysqli_store_result() and mysqli_use_result() cannot be tested, because one would need to cause an error inside the C function to test it // Check that none of the above would have caused any error messages if MYSQL_REPORT_ERROR would // not have been set. If that would be the case, the test would be broken. mysqli_report(MYSQLI_REPORT_OFF); mysqli_multi_query($link, "BAR; FOO;"); mysqli_query($link, "FOO"); mysqli_change_user($link, "This might work if you accept anonymous users in your setup", "password", $db); mysqli_kill($link, -1); mysqli_prepare($link, "FOO"); mysqli_real_query($link, "FOO"); mysqli_select_db($link, "Oh lord, let this be an unknown database name"); /* Internal macro MYSQL_REPORT_STMT_ERROR */ mysqli_report(MYSQLI_REPORT_ERROR); $stmt = mysqli_stmt_init($link); mysqli_stmt_prepare($stmt, "FOO"); $stmt = mysqli_stmt_init($link); mysqli_stmt_prepare($stmt, "SELECT id FROM test WHERE id > ?"); $id = 1; mysqli_kill($link, mysqli_thread_id($link)); mysqli_stmt_bind_param($stmt, "i", $id); mysqli_stmt_close($stmt); mysqli_close($link); /* mysqli_stmt_execute() = mysql_stmt_execute cannot be tested from PHP */ if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[008] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); $stmt = mysqli_stmt_init($link); mysqli_stmt_prepare($stmt, "SELECT id FROM test WHERE id > ?"); $id = 1; mysqli_stmt_bind_param($stmt, "i", $id); // mysqli_kill($link, mysqli_thread_id($link)); mysqli_stmt_execute($stmt); mysqli_stmt_close($stmt); mysqli_close($link); /* mysqli_kill() "trick" does not work for any of the following because of an E_COMMANDS_OUT_OF_SYNC */ /* mysqli_stmt_bind_result() = mysql_stmt_bind_result() cannot be tested from PHP */ /* mysqli_stmt_fetch() = mysql_stmt_fetch() cannot be tested from PHP */ /* mysqli_stmt_result_metadata() = mysql_stmt_result_metadata() cannot be tested from PHP */ /* mysqli_stmt_store_result() = mysql_stmt_store_result() cannot be tested from PHP */ // Check mysqli_report(MYSQLI_REPORT_OFF); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[010] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); $stmt = mysqli_stmt_init($link); mysqli_stmt_prepare($stmt, "FOO"); $stmt = mysqli_stmt_init($link); mysqli_stmt_prepare($stmt, "SELECT id FROM test WHERE id > ?"); $id = 1; mysqli_kill($link, mysqli_thread_id($link)); mysqli_stmt_bind_param($stmt, "i", $id); mysqli_stmt_close($stmt); mysqli_close($link); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[011] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); $stmt = mysqli_stmt_init($link); mysqli_stmt_prepare($stmt, "SELECT id FROM test WHERE id > ?"); $id = 1; mysqli_stmt_bind_param($stmt, "i", $id); mysqli_kill($link, mysqli_thread_id($link)); mysqli_stmt_execute($stmt); mysqli_stmt_close($stmt); mysqli_close($link); /* MYSQLI_REPORT_STRICT MYSQLI_REPORT_STRICT ---> php_mysqli_report_error() -> MYSQLI_REPORT_MYSQL_ERROR, MYSQLI_REPORT_STMT_ERROR -> already tested php_mysqli_throw_sql_exception() -> mysqli_real_connect() mysqli_connect() can't be tested: mysqli_query() via mysql_use_result()/mysql_store_result() */ mysqli_report(MYSQLI_REPORT_OFF); mysqli_report(MYSQLI_REPORT_STRICT); try { if ($link = mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket)) printf("[012] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", $host, $user . 'unknown_really', $db, $port, $socket); mysqli_close($link); } catch (mysqli_sql_exception $e) { printf("[013] %s\n", $e->getMessage()); } try { if (!$link = mysqli_init()) printf("[014] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); if ($link = mysqli_real_connect($link, $host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket)) printf("[015] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", $host, $user . 'unknown_really', $db, $port, $socket); mysqli_close($link); } catch (mysqli_sql_exception $e) { printf("[016] %s\n", $e->getMessage()); } /* MYSQLI_REPORT_INDEX ---> mysqli_query() mysqli_stmt_execute() mysqli_prepare() mysqli_real_query() mysqli_store_result() mysqli_use_result() No test, because of to many prerequisites: - Server needs to be started with and --log-slow-queries --log-queries-not-using-indexes - query must cause the warning on all MySQL versions TODO: */ $log_slow_queries = false; $log_queries_not_using_indexes = false; if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[017] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); if (!$res = mysqli_query($link, "SHOW VARIABLES LIKE 'log_slow_queries'")) printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$row = mysqli_fetch_assoc($res)) printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $log_slow_query = ('ON' == $row['Value']); if (mysqli_get_server_version($link) >= 51011) { if (!$res = mysqli_query($link, "SHOW VARIABLES LIKE 'log_queries_not_using_indexes'")) printf("[020] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$row = mysqli_fetch_assoc($res)) printf("[021] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $log_queries_not_using_indexes = ('ON' == $row['Value']); if ($log_slow_queries && $log_queries_not_using_indexes) { for ($i = 100; $i < 20000; $i++) { if (!mysqli_query($link, "INSERT INTO test(id, label) VALUES ($i, 'z')")) printf("[022 - %d] [%d] %s\n", $i - 99, mysqli_errno($link), mysqli_error($link)); } if (!$res = @mysqli_query($link, "SELECT id, label FROM test WHERE id = 1323")) printf("[023] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_free_result($res); mysqli_report(MYSQLI_REPORT_OFF); mysqli_report(MYSQLI_REPORT_INDEX); } } print "done!"; ?> --EXPECTF-- Warning: mysqli_multi_query(): (%d/%d): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'BAR; FOO' at line 1 in %s on line %d Warning: mysqli_query(): (%d/%d): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FOO' at line 1 in %s on line %d Warning: mysqli_change_user(): (%d/%d): Access denied for user '0123456789-10-456789-20-456789-%s'@'%s' (using password: YES) in %s on line %d Warning: mysqli_kill(): processid should have positive value in %s on line %d Warning: mysqli_prepare(): (%d/%d): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FOO' at line 1 in %s on line %d Warning: mysqli_real_query(): (%d/%d): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FOO' at line 1 in %s on line %d Warning: mysqli_kill(): processid should have positive value in %s on line %d Warning: mysqli_stmt_prepare(): (%d/%d): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FOO' at line 1 in %s on line %d [013] Access denied for user '%s'@'%s' (using password: YES) [016] Access denied for user '%s'@'%s' (using password: YES) done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_report_wo_ps.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_report_wo_ps.phpt +++ php-src/ext/mysqli/tests/mysqli_report_wo_ps.phpt --TEST-- mysqli_report() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (NULL !== ($tmp = @mysqli_report())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = mysqli_report(-1))) printf("[002] Expecting boolean/true even for invalid flags, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_ERROR))) printf("[003] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_STRICT))) printf("[004] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_INDEX))) printf("[005] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_ALL))) printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_OFF))) printf("[008] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); /* Internal macro MYSQL_REPORT_ERROR */ mysqli_report(MYSQLI_REPORT_ERROR); mysqli_multi_query($link, "BAR; FOO;"); mysqli_query($link, "FOO"); mysqli_change_user($link, "0123456789-10-456789-20-456789-30-456789-40-456789-50-456789-60-456789-70-456789-80-456789-90-456789", "password", $db); mysqli_kill($link, -1); // mysqli_ping() cannot be tested, because one would need to cause an error inside the C function to test it mysqli_real_query($link, "FOO"); if (@mysqli_select_db($link, "Oh lord, let this be an unknown database name")) printf("[009] select_db should have failed\n"); // mysqli_store_result() and mysqli_use_result() cannot be tested, because one would need to cause an error inside the C function to test it // Check that none of the above would have caused any error messages if MYSQL_REPORT_ERROR would // not have been set. If that would be the case, the test would be broken. mysqli_report(MYSQLI_REPORT_OFF); mysqli_multi_query($link, "BAR; FOO;"); mysqli_query($link, "FOO"); mysqli_change_user($link, "This might work if you accept anonymous users in your setup", "password", $db); mysqli_kill($link, -1); mysqli_real_query($link, "FOO"); mysqli_select_db($link, "Oh lord, let this be an unknown database name"); mysqli_report(MYSQLI_REPORT_OFF); mysqli_report(MYSQLI_REPORT_STRICT); try { if ($link = mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket)) printf("[010] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", $host, $user . 'unknown_really', $db, $port, $socket); mysqli_close($link); } catch (mysqli_sql_exception $e) { printf("[011] %s\n", $e->getMessage()); } try { if (!$link = mysqli_init()) printf("[012] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); if ($link = mysqli_real_connect($link, $host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket)) printf("[013] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", $host, $user . 'unknown_really', $db, $port, $socket); mysqli_close($link); } catch (mysqli_sql_exception $e) { printf("[014] %s\n", $e->getMessage()); } print "done!"; ?> --EXPECTF-- Warning: mysqli_multi_query(): (%d/%d): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'BAR; FOO' at line 1 in %s on line %d Warning: mysqli_query(): (%d/%d): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FOO' at line 1 in %s on line %d Warning: mysqli_change_user(): (%d/%d): Access denied for user '0123456789-10-456789-20-456789-%s'@'%s' (using password: YES) in %s on line %d Warning: mysqli_kill(): processid should have positive value in %s on line %d Warning: mysqli_real_query(): (%d/%d): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FOO' at line 1 in %s on line %d Warning: mysqli_kill(): processid should have positive value in %s on line %d [011] Access denied for user '%s'@'%s' (using password: YES) [014] Access denied for user '%s'@'%s' (using password: YES) done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_result_references.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_result_references.phpt +++ php-src/ext/mysqli/tests/mysqli_result_references.phpt --TEST-- References to result sets --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php require_once('connect.inc'); require_once('table.inc'); $references = array(); if (!(mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id ASC LIMIT 2")) || !($res = mysqli_store_result($link))) printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $idx = 0; while ($row = mysqli_fetch_assoc($res)) { /* mysqlnd: force seperation - create copies */ $references[$idx] = array( 'id' => &$row['id'], 'label' => $row['label'] . ''); $references[$idx++]['id'] += 0; } mysqli_close($link); mysqli_data_seek($res, 0); while ($row = mysqli_fetch_assoc($res)) { /* mysqlnd: force seperation - create copies */ $references[$idx] = array( 'id' => &$row['id'], 'label' => $row['label'] . ''); $references[$idx++]['id'] += 0; } mysqli_free_result($res); if (!$link = mysqli_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 (!(mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id ASC LIMIT 2")) || !($res = mysqli_use_result($link))) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); while ($row = mysqli_fetch_assoc($res)) { /* mysqlnd: force seperation - create copies*/ $references[$idx] = array( 'id' => &$row['id'], 'label' => $row['label'] . ''); $references[$idx]['id2'] = &$references[$idx]['id']; $references[$idx]['id'] += 1; $references[$idx++]['id2'] += 1; } $references[$idx++] = &$res; mysqli_free_result($res); debug_zval_dump($references); if (!(mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id ASC LIMIT 1")) || !($res = mysqli_use_result($link))) printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = array(); while ($row = mysqli_fetch_assoc($res)) { $tmp[] = $row; } $tmp = unserialize(serialize($tmp)); debug_zval_dump($tmp); mysqli_free_result($res); mysqli_close($link); print "done!"; ?> --EXPECTF-- array(7) refcount(2){ [0]=> array(2) refcount(1){ ["id"]=> long(1) refcount(1) ["label"]=> string(1) "a" refcount(1) } [1]=> array(2) refcount(1){ ["id"]=> long(2) refcount(1) ["label"]=> string(1) "b" refcount(1) } [2]=> array(2) refcount(1){ ["id"]=> long(1) refcount(1) ["label"]=> string(1) "a" refcount(1) } [3]=> array(2) refcount(1){ ["id"]=> long(2) refcount(1) ["label"]=> string(1) "b" refcount(1) } [4]=> array(3) refcount(1){ ["id"]=> &long(3) refcount(2) ["label"]=> string(1) "a" refcount(1) ["id2"]=> &long(3) refcount(2) } [5]=> array(3) refcount(1){ ["id"]=> &long(4) refcount(2) ["label"]=> string(1) "b" refcount(1) ["id2"]=> &long(4) refcount(2) } [6]=> &object(mysqli_result)#2 (0) refcount(2){ } } array(1) refcount(2){ [0]=> array(2) refcount(1){ ["id"]=> string(1) "1" refcount(1) ["label"]=> string(1) "a" refcount(1) } } done! --UEXPECTF-- array(7) refcount(2){ [0]=> array(2) refcount(1){ [u"id" { 0069 0064 }]=> long(1) refcount(1) [u"label" { 006c 0061 0062 0065 006c }]=> unicode(1) "a" { 0061 } refcount(1) } [1]=> array(2) refcount(1){ [u"id" { 0069 0064 }]=> long(2) refcount(1) [u"label" { 006c 0061 0062 0065 006c }]=> unicode(1) "b" { 0062 } refcount(1) } [2]=> array(2) refcount(1){ [u"id" { 0069 0064 }]=> long(1) refcount(1) [u"label" { 006c 0061 0062 0065 006c }]=> unicode(1) "a" { 0061 } refcount(1) } [3]=> array(2) refcount(1){ [u"id" { 0069 0064 }]=> long(2) refcount(1) [u"label" { 006c 0061 0062 0065 006c }]=> unicode(1) "b" { 0062 } refcount(1) } [4]=> array(3) refcount(1){ [u"id" { 0069 0064 }]=> &long(3) refcount(2) [u"label" { 006c 0061 0062 0065 006c }]=> unicode(1) "a" { 0061 } refcount(1) [u"id2" { 0069 0064 0032 }]=> &long(3) refcount(2) } [5]=> array(3) refcount(1){ [u"id" { 0069 0064 }]=> &long(4) refcount(2) [u"label" { 006c 0061 0062 0065 006c }]=> unicode(1) "b" { 0062 } refcount(1) [u"id2" { 0069 0064 0032 }]=> &long(4) refcount(2) } [6]=> &object(mysqli_result)#2 (0) refcount(2){ } } array(1) refcount(2){ [0]=> array(2) refcount(1){ [u"id" { 0069 0064 }]=> unicode(1) "1" { 0031 } refcount(1) [u"label" { 006c 0061 0062 0065 006c }]=> unicode(1) "a" { 0061 } refcount(1) } } done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_result_references_mysqlnd.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_result_references_mysqlnd.phpt +++ php-src/ext/mysqli/tests/mysqli_result_references_mysqlnd.phpt --TEST-- References to result sets - mysqlnd (no copies but references) --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('connect.inc'); if (!$IS_MYSQLND) die("skip Test for mysqlnd only"); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php require_once('connect.inc'); require_once('table.inc'); $references = array(); if (!(mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id ASC LIMIT 1")) || !($res = mysqli_store_result($link))) printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $idx = 0; while ($row = mysqli_fetch_assoc($res)) { /* will overwrite itself */ $references[$idx]['row_ref'] = &$row; $references[$idx]['row_copy'] = $row; $references[$idx]['id_ref'] = &$row['id']; $references[$idx++]['id_copy'] = $row['id']; } mysqli_free_result($res); if (!(mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id ASC LIMIT 2")) || !($res = mysqli_use_result($link))) printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $rows = array(); for ($i = 0; $i < 2; $i++) { $rows[$i] = mysqli_fetch_assoc($res); $references[$idx]['row_ref'] = &$rows[$i]; $references[$idx]['row_copy'] = $rows[$i]; $references[$idx]['id_ref'] = &$rows[$i]['id']; $references[$idx]['id_copy'] = $rows[$i]['id']; /* enforce seperation */ $references[$idx]['id_copy_mod']= $rows[$i]['id'] + 0; } mysqli_free_result($res); debug_zval_dump($references); print "done!"; ?> --EXPECTF-- array(2) refcount(2){ [0]=> array(4) refcount(1){ ["row_ref"]=> &NULL refcount(2) ["row_copy"]=> array(2) refcount(1){ ["id"]=> string(1) "1" refcount(2) ["label"]=> string(1) "a" refcount(2) } ["id_ref"]=> string(1) "1" refcount(1) ["id_copy"]=> string(1) "1" refcount(1) } [1]=> array(5) refcount(1){ ["row_ref"]=> &array(2) refcount(2){ ["id"]=> &string(1) "2" refcount(2) ["label"]=> string(1) "b" refcount(3) } ["row_copy"]=> array(2) refcount(1){ ["id"]=> string(1) "2" refcount(2) ["label"]=> string(1) "b" refcount(3) } ["id_ref"]=> &string(1) "2" refcount(2) ["id_copy"]=> string(1) "2" refcount(1) ["id_copy_mod"]=> long(2) refcount(1) } } done! --UEXPECTF-- array(2) refcount(2){ [0]=> array(4) refcount(1){ [u"row_ref" { 0072 006f 0077 005f 0072 0065 0066 }]=> &NULL refcount(2) [u"row_copy" { 0072 006f 0077 005f 0063 006f 0070 0079 }]=> array(2) refcount(1){ [u"id" { 0069 0064 }]=> unicode(1) "1" { 0031 } refcount(2) [u"label" { 006c 0061 0062 0065 006c }]=> unicode(1) "a" { 0061 } refcount(2) } [u"id_ref" { 0069 0064 005f 0072 0065 0066 }]=> unicode(1) "1" { 0031 } refcount(1) [u"id_copy" { 0069 0064 005f 0063 006f 0070 0079 }]=> unicode(1) "1" { 0031 } refcount(1) } [1]=> array(5) refcount(1){ [u"row_ref" { 0072 006f 0077 005f 0072 0065 0066 }]=> &array(2) refcount(2){ [u"id" { 0069 0064 }]=> &unicode(1) "2" { 0032 } refcount(2) [u"label" { 006c 0061 0062 0065 006c }]=> unicode(1) "b" { 0062 } refcount(3) } [u"row_copy" { 0072 006f 0077 005f 0063 006f 0070 0079 }]=> array(2) refcount(1){ [u"id" { 0069 0064 }]=> unicode(1) "2" { 0032 } refcount(2) [u"label" { 006c 0061 0062 0065 006c }]=> unicode(1) "b" { 0062 } refcount(3) } [u"id_ref" { 0069 0064 005f 0072 0065 0066 }]=> &unicode(1) "2" { 0032 } refcount(2) [u"id_copy" { 0069 0064 005f 0063 006f 0070 0079 }]=> unicode(1) "2" { 0032 } refcount(1) [u"id_copy_mod" { 0069 0064 005f 0063 006f 0070 0079 005f 006d 006f 0064 }]=> long(2) refcount(1) } } done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_rollback.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_rollback.phpt +++ php-src/ext/mysqli/tests/mysqli_rollback.phpt --TEST-- mysqli_rollback() --SKIPIF-- <?php ?> <?php ?> <?PHP require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('connect.inc'); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { die(sprintf("skip Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket)); } if (!$res = mysqli_query($link, "SHOW VARIABLES LIKE 'have_innodb'")) { die(sprintf("skip Cannot fetch have_innodb variable\n")); } $row = mysqli_fetch_row($res); mysqli_free_result($res); mysqli_close($link); if ($row[1] == "DISABLED" || $row[1] == "NO") { die(sprintf("skip Innodb support is not installed or enabled.")); } ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_rollback())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_rollback($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_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); if (!is_null($tmp = @mysqli_rollback($link, 'foo'))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = mysqli_autocommit($link, false))) printf("[005] Cannot turn off autocommit, expecting true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, 'CREATE TABLE test(id INT) ENGINE = InnoDB')) printf("[007] Cannot create test table, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, 'INSERT INTO test(id) VALUES (1)')) printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_rollback($link); if ($tmp !== true) printf("[009] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!$res = mysqli_query($link, 'SELECT COUNT(*) AS num FROM test')) printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); if (0 != $tmp['num']) printf("[12] Expecting 0 rows in table test, found %d rows\n", $tmp['num']); mysqli_free_result($res); if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_close($link); if (!is_null($tmp = mysqli_rollback($link))) printf("[014] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!\n"; ?> --EXPECTF-- Warning: mysqli_rollback(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_select_db.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_select_db.phpt +++ php-src/ext/mysqli/tests/mysqli_select_db.phpt --TEST-- mysqli_select_db() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_select_db())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_select_db($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_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); if (!is_null($tmp = @mysqli_select_db($link, $db, "foo"))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); /* does not make too much sense, unless we have access to at least one more database than $db */ if (!mysqli_select_db($link, $db)) printf("[005] Cannot select DB %s, [%d] %s\n", $db, mysqli_errno($link), mysqli_error($link)); if (!$res = mysqli_query($link, "SELECT DATABASE() AS dbname")) printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$row = mysqli_fetch_assoc($res)) printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if ($row['dbname'] !== (string)$db) printf("[008] Expecting database '%s', found '%s'\n", $db, $row['dbname']); mysqli_free_result($res); if (mysqli_select_db($link, 'mysql')) { // Yippie, a second database to play with - that's great because mysqli_select_db // ($db) was done by mysqli__connect() already and the previous test // was quite useless if (!$res = mysqli_query($link, "SELECT DATABASE() AS dbname")) printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$row = mysqli_fetch_assoc($res)) printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (strtolower($row['dbname']) !== 'mysql') printf("[011] Expecting database 'mysql', found '%s'\n", $row['dbname']); mysqli_free_result($res); } mysqli_report(MYSQLI_REPORT_OFF); mysqli_select_db($link, 'I can not imagine that this database exists'); mysqli_report(MYSQLI_REPORT_ERROR); mysqli_select_db($link, 'I can not imagine that this database exists'); mysqli_close($link); if (NULL !== ($tmp = mysqli_select_db($link, $db))) printf("[012] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!\n"; ?> --EXPECTF-- Warning: mysqli_select_db(): (%d/%d): Unknown database '%s' in %s on line %d Warning: mysqli_select_db(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_set_charset.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_set_charset.phpt +++ php-src/ext/mysqli/tests/mysqli_set_charset.phpt --TEST-- mysqli_set_charset() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); if (!function_exists('mysqli_set_charset')) die("skip Function not available"); if (ini_get("unicode.semantics")) die("skip: mysqli_set_charset() is disabled in unicode"); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_set_charset())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_set_charset($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_set_charset($link, $link))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysqli_query($link, 'SELECT version() AS server_version')) printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_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 = mysqli_query($link, 'SELECT @@character_set_connection AS charset, @@collation_connection AS collation')) printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); if (!$character_set_connection = $tmp['charset']) printf("[008] Cannot determine current character set and collation\n"); $new_charset = ('latin1' == $character_set_connection) ? 'latin2' : 'latin1'; if (!$res = mysqli_query($link, sprintf('SHOW CHARACTER SET LIKE "%s"', $new_charset), MYSQLI_STORE_RESULT)) printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (mysqli_num_rows($res) == 0) printf("[010] Test will fail, because alternative test character set '%s' seems not supported\n", $new_charset); if (false !== ($ret = mysqli_set_charset($link, "this is not a valid character set"))) printf("[011] Expecting boolean/false because of invalid character set, got %s/%s\n", gettype($ret), $ret); mysqli_close($link); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[012] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (true !== ($ret = mysqli_set_charset($link, $new_charset))) printf("[013] Expecting boolean/true, got %s/%s\n", gettype($ret), $ret); if (!$res = mysqli_query($link, 'SELECT @@character_set_connection AS charset, @@collation_connection AS collation')) printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); if ($new_charset !== $tmp['charset']) printf("[015] Character set not changed? Expecting %s, got %s\n", $new_charset, $tmp['charset']); if (!$res = mysqli_query($link, "SHOW CHARACTER SET")) printf("[016] Cannot get list of character sets\n"); while ($tmp = mysqli_fetch_assoc($res)) { if ('ucs2' == $tmp['Charset']) continue; /* Uncomment to see where it hangs - var_dump($tmp); flush(); */ if (!@mysqli_set_charset($link, $tmp['Charset'])) { printf("[017] Cannot set character set to '%s', [%d] %s\n", $tmp['Charset'], mysqli_errno($link), mysqli_error($link)); continue; } /* Uncomment to see where it hangs - var_dump($tmp); flush(); */ if (!mysqli_query($link, sprintf("SET NAMES %s", mysqli_real_escape_string($link, $tmp['Charset'])))) printf("[018] Cannot run SET NAMES %s, [%d] %s\n", $tmp['Charset'], mysqli_errno($link), mysqli_error($link)); } mysqli_free_result($res); mysqli_close($link); if (NULL !== ($tmp = mysqli_set_charset($link, $new_charset))) printf("[016] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_set_charset(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_set_opt.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_set_opt.phpt +++ php-src/ext/mysqli/tests/mysqli_set_opt.phpt --TEST-- mysqli_set_opt() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_set_opt())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_set_opt($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); $link = mysqli_init(); if (!is_null($tmp = @mysqli_set_opt($link, MYSQLI_OPT_CONNECT_TIMEOUT))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_set_opt($link, "s", 'extra_my.cnf'))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_set_opt($link, MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT=0', 'foo'))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); // print "run_tests.php don't fool me with your 'ungreedy' expression '.+?'!\n"; var_dump(mysqli_set_opt($link, MYSQLI_READ_DEFAULT_GROUP, 'extra_my.cnf')); var_dump(mysqli_set_opt($link, MYSQLI_READ_DEFAULT_FILE, 'extra_my.cnf')); var_dump(mysqli_set_opt($link, MYSQLI_OPT_CONNECT_TIMEOUT, 10)); var_dump(mysqli_set_opt($link, MYSQLI_OPT_LOCAL_INFILE, 1)); var_dump(mysqli_set_opt($link, MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT=0')); var_dump(mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)); var_dump(mysqli_set_opt($link, MYSQLI_READ_DEFAULT_GROUP, 'extra_my.cnf')); var_dump(mysqli_set_opt($link, MYSQLI_READ_DEFAULT_FILE, 'extra_my.cnf')); var_dump(mysqli_set_opt($link, MYSQLI_OPT_CONNECT_TIMEOUT, 10)); var_dump(mysqli_set_opt($link, MYSQLI_OPT_LOCAL_INFILE, 1)); var_dump(mysqli_set_opt($link, MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT=0')); var_dump(mysqli_set_opt($link, MYSQLI_CLIENT_SSL, 'not an mysqli_option')); mysqli_close($link); var_dump(mysqli_set_opt($link, MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT=1')); print "done!"; ?> --EXPECTF-- bool(true) bool(true) bool(true) bool(true) bool(true) bool(true) bool(true) bool(true) bool(true) bool(true) bool(true) bool(false) Warning: mysqli_set_opt(): Couldn't fetch mysqli in %s on line %d NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_set_opt_numeric_and_datetime_as_unicode.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_set_opt_numeric_and_datetime_as_unicode.phpt +++ php-src/ext/mysqli/tests/mysqli_set_opt_numeric_and_datetime_as_unicode.phpt --TEST-- mysqli_set_opt() - MYSQLI_OPT_NUMERIC_AND_DATETIME_AS_UNICODE --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); if (!function_exists('unicode_semantics')) die("skip needs PHP 6"); if (!unicode_semantics()) die("skip works only in unicode mode"); if (!stristr(mysqli_get_client_info(), "mysqlnd")) die("skip works only with mysqlnd"); ?> --FILE-- <?php include "connect.inc"; include "table.inc"; if (true !== ($tmp = mysqli_set_opt($link, MYSQLI_OPT_NUMERIC_AND_DATETIME_AS_UNICODE, 1))) printf("[001] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, 'ALTER TABLE test ADD col_date DATE, ADD col_time TIME, ADD col_timestamp TIMESTAMP, ADD col_datetime DATETIME')) printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, 'UPDATE test SET col_date = NOW(), col_time = NOW(), col_timestamp = NOW(), col_datetime = NOW()')) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$res = mysqli_query($link, 'SELECT * FROM test')) printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$row = mysqli_fetch_assoc($res)) printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_unicode($row['col_time']) || '' == $row['col_time']) printf("[006] Expecting unicode/any, got %s/%s\n", gettype($row['col_time']), $row['col_time']); if (!is_unicode($row['col_timestamp']) || '' == $row['col_timestamp']) printf("[007] Expecting unicode/any, got %s/%s\n", gettype($row['col_timestamp']), $row['col_timestamp']); if (!is_unicode($row['col_datetime']) || '' == $row['col_datetime']) printf("[008] Expecting unicode/any, got %s/%s\n", gettype($row['col_datetime']), $row['col_datetime']); if (!is_unicode($row['col_date']) || '' == $row['col_date']) printf("[009] Expecting unicode/any, got %s/%s\n", gettype($row['col_date']), $row['col_date']); mysqli_free_result($res); if (true !== ($tmp = mysqli_set_opt($link, MYSQLI_OPT_NUMERIC_AND_DATETIME_AS_UNICODE, 0))) printf("[010] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!$res = mysqli_query($link, 'SELECT * FROM test')) printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$row = mysqli_fetch_assoc($res)) printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (is_unicode($row['col_time']) || '' == $row['col_time']) printf("[013] Expecting (binary) string/any, got %s/%s\n", gettype($row['col_time']), $row['col_time']); if (is_unicode($row['col_timestamp']) || '' == $row['col_timestamp']) printf("[014] Expecting (binary) string/any, got %s/%s\n", gettype($row['col_timestamp']), $row['col_timestamp']); if (is_unicode($row['col_datetime']) || '' == $row['col_datetime']) printf("[015] Expecting (binary) string/any, got %s/%s\n", gettype($row['col_datetime']), $row['col_datetime']); if (is_unicode($row['col_date']) || '' == $row['col_date']) printf("[016] Expecting (binary) string/any, got %s/%s\n", gettype($row['col_date']), $row['col_date']); mysqli_free_result($res); if (true !== ($tmp = mysqli_set_opt($link, MYSQLI_OPT_NUMERIC_AND_DATETIME_AS_UNICODE, 1))) printf("[017] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!$res = mysqli_query($link, 'SELECT * FROM test')) printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$row = mysqli_fetch_assoc($res)) printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_unicode($row['col_time']) || '' == $row['col_time']) printf("[020] Expecting unicode/any, got %s/%s\n", gettype($row['col_time']), $row['col_time']); mysqli_free_result($res); if (!$stmt = mysqli_stmt_init($link)) printf("[021] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $col_date = $col_time = $col_datetime = $col_timestamp = null; if (!mysqli_stmt_prepare($stmt, 'SELECT col_date, col_time, col_datetime, col_timestamp FROM test') || !mysqli_stmt_execute($stmt) || !mysqli_stmt_bind_result($stmt, $col_date, $col_time, $col_datetime, $col_timestamp) || !mysqli_stmt_fetch($stmt)) printf("[022] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!is_unicode($col_date) || '' == $col_date) printf("[023] Expecting unicode/any, got %s/%s\n", gettype($col_date), $col_date); if (!is_unicode($col_time) || '' == $col_time) printf("[024] Expecting unicode/any, got %s/%s\n", gettype($col_time), $col_time); if (!is_unicode($col_datetime) || '' == $col_datetime) printf("[025] Expecting unicode/any, got %s/%s\n", gettype($col_datetime), $col_datetime); if (!is_unicode($col_timestamp) || '' == $col_timestamp) printf("[026] Expecting unicode/any, got %s/%s\n", gettype($col_timestamp), $col_timestamp); mysqli_stmt_close($stmt); if (true !== ($tmp = mysqli_set_opt($link, MYSQLI_OPT_NUMERIC_AND_DATETIME_AS_UNICODE, 0))) printf("[027] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!$stmt = mysqli_stmt_init($link)) printf("[028] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $col_date = $col_time = $col_datetime = $col_timestamp = null; if (!mysqli_stmt_prepare($stmt, 'SELECT col_date, col_time, col_datetime, col_timestamp FROM test') || !mysqli_stmt_execute($stmt) || !mysqli_stmt_bind_result($stmt, $col_date, $col_time, $col_datetime, $col_timestamp) || !mysqli_stmt_fetch($stmt)) printf("[029] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (is_unicode($col_date) || '' == $col_date) printf("[030] Expecting (binary) string/any, got %s/%s\n", gettype($col_date), $col_date); if (is_unicode($col_time) || '' == $col_time) printf("[031] Expecting (binary) string/any, got %s/%s\n", gettype($col_time), $col_time); if (is_unicode($col_datetime) || '' == $col_datetime) printf("[032] Expecting (binary) string/any, got %s/%s\n", gettype($col_datetime), $col_datetime); if (is_unicode($col_timestamp) || '' == $col_timestamp) printf("[033] Expecting (binary) string/any, got %s/%s\n", gettype($col_timestamp), $col_timestamp); mysqli_stmt_close($stmt); mysqli_close($link); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_sqlstate.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_sqlstate.phpt +++ php-src/ext/mysqli/tests/mysqli_sqlstate.phpt --TEST-- mysqli_sqlstate() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_sqlstate())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_sqlstate($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); var_dump(@mysqli_sqlstate($link, "foo")); var_dump(mysqli_sqlstate($link)); mysqli_query($link, "SELECT unknown_column FROM test"); var_dump(mysqli_sqlstate($link)); mysqli_free_result(mysqli_query($link, "SELECT id FROM test")); var_dump(mysqli_sqlstate($link)); mysqli_close($link); var_dump(mysqli_sqlstate($link)); print "done!"; ?> --EXPECTF-- NULL %s(5) "00000" %s(5) "42S22" %s(5) "00000" Warning: mysqli_sqlstate(): Couldn't fetch mysqli in %s on line %d NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_ssl_set.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_ssl_set.phpt +++ php-src/ext/mysqli/tests/mysqli_ssl_set.phpt --TEST-- mysqli_ssl_set() - test is a stub! --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); if (!function_exists('mysqli_ssl_set')) die("skip function not available"); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_ssl_set())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_ssl_set($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_ssl_set($link, $link))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_ssl_set($link, $link, $link))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_ssl_set($link, $link, $link, $link))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_ssl_set($link, $link, $link, $link, $link))) printf("[006] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); /* This function always returns TRUE value. $link = mysqli_init(); if (NULL !== ($tmp = @mysqli_ssl_set( $link, 'The path name to the key file.', 'The path name to the certificate file.', 'The path name to the certificate authority file.', 'The pathname to a directory that contains trusted SSL CA certificates in PEM format.', 'A list of allowable ciphers to use for SSL encryption.'))) printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); If SSL setup is incorrect mysqli_real_connect() will return an error when you attempt to connect. ... and the above SSL setup should be always incorrect. if (false !== ($tmp = mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))) printf("[008] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); */ print "done!\n"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stat.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stat.phpt +++ php-src/ext/mysqli/tests/mysqli_stat.phpt --TEST-- mysqli_stat() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stat())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stat($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!is_null($tmp = @mysqli_stat($link, "foo"))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if ((!is_string($tmp = mysqli_stat($link))) || ('' === $tmp)) printf("[004] Expecting non empty string, got %s/'%s', [%d] %s\n", gettype($tmp), $tmp, mysqli_errno($link), mysql_error($link)); mysqli_close($link); if (!is_null($tmp = mysqli_stat($link))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_stat(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_affected_rows.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_affected_rows.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_affected_rows.phpt --TEST-- mysqli_stmt_affected_rows() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_affected_rows())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_affected_rows($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { printf("Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); } $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, 'DROP TABLE IF EXISTS test') || !mysqli_stmt_execute($stmt)) { printf("[003] Failed to drop old test table: [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); } if (!mysqli_stmt_prepare($stmt, 'CREATE TABLE test(id INT, label CHAR(1), PRIMARY KEY(id)) ENGINE = ' . $engine) || !mysqli_stmt_execute($stmt)) { printf("[004] Failed to create test table: [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); } if (0 !== ($tmp = mysqli_stmt_affected_rows($stmt))) printf("[005] Expecting int/0, got %s/'%s'\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, 'INSERT INTO test(id, label) VALUES (1, "a")') || !mysqli_stmt_execute($stmt)) printf("[006] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); mysqli_stmt_close($stmt); $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, 'INSERT INTO test(id, label) VALUES (100, "z")') || !mysqli_stmt_execute($stmt)) printf("[007] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (1 !== ($tmp = mysqli_stmt_affected_rows($stmt))) printf("[008] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, 'INSERT INTO test(id, label) VALUES (100, "z")') || !mysqli_stmt_execute($stmt)) // NOTE: the error message varies with the MySQL Server version, dump only the error code! printf("[009] [%d] (error message varies with the MySQL Server version, check the error code)\n", mysqli_stmt_errno($stmt)); /* an error occured: affected rows should return -1 */ if (-1 !== ($tmp = mysqli_stmt_affected_rows($stmt))) printf("[010] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, 'INSERT INTO test(id, label) VALUES (1, "a") ON DUPLICATE KEY UPDATE id = 4') || !mysqli_stmt_execute($stmt)) printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (2 !== ($tmp = mysqli_stmt_affected_rows($stmt))) printf("[012] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (2, 'b'), (3, 'c')") || !mysqli_stmt_execute($stmt)) printf("[013] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (2 !== ($tmp = mysqli_stmt_affected_rows($stmt))) printf("[014] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, "INSERT IGNORE INTO test(id, label) VALUES (1, 'a')") || !mysqli_stmt_execute($stmt)) printf("[015] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (1 !== ($tmp = mysqli_stmt_affected_rows($stmt))) printf("[016] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); if (!($res = mysqli_query($link, "SELECT count(id) AS num FROM test")) || !($tmp = mysqli_fetch_assoc($res))) printf("[017] [%d] %s\n", mysqli_errnor($link), mysqli_error($link)); $num = (int)$tmp['num']; mysqli_free_result($res); mysqli_stmt_close($stmt); $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) SELECT id + 10, label FROM test") || !mysqli_stmt_execute($stmt)) printf("[018] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if ($num !== ($tmp = mysqli_stmt_affected_rows($stmt))) printf("[019] Expecting int/%d, got %s/%s\n", $num, gettype($tmp), $tmp); mysqli_stmt_close($stmt); $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, "REPLACE INTO test(id, label) values (4, 'd')") || !mysqli_stmt_execute($stmt)) printf("[020] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (2 !== ($tmp = mysqli_stmt_affected_rows($stmt))) printf("[021] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, "REPLACE INTO test(id, label) values (5, 'e')") || !mysqli_stmt_execute($stmt)) printf("[022] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (1 !== ($tmp = mysqli_stmt_affected_rows($stmt))) printf("[023] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, "UPDATE test SET label = 'a' WHERE id = 2") || !mysqli_stmt_execute($stmt)) printf("[024] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (1 !== ($tmp = mysqli_stmt_affected_rows($stmt))) printf("[025] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, "UPDATE test SET label = 'a' WHERE id = 2") || !mysqli_stmt_execute($stmt)) printf("[026] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (0 !== ($tmp = mysqli_stmt_affected_rows($stmt))) printf("[027] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, "UPDATE test SET label = 'a' WHERE id = 100") || !mysqli_stmt_execute($stmt)) printf("[028] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (1 !== ($tmp = mysqli_stmt_affected_rows($stmt))) printf("[029] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, "DROP TABLE IF EXISTS test") || !mysqli_stmt_execute($stmt)) printf("[030] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); mysqli_stmt_close($stmt); if (!is_null($tmp = mysqli_stmt_affected_rows($stmt))) printf("[031] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); print "done!"; ?> --EXPECTF-- [009] [%d] (error message varies with the MySQL Server version, check the error code) Warning: mysqli_stmt_affected_rows(): Couldn't fetch mysqli_stmt in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_attr_get.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_attr_get.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_attr_get.phpt --TEST-- mysqli_stmt_attr_get() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_attr_get())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_attr_get($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_attr_get($link, $link))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!is_null($tmp = @mysqli_stmt_attr_get($link, $link))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); $valid_attr = array("max_length" => MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH); if (mysqli_get_client_version() > 50003) $valid_attr["cursor_type"] = MYSQLI_STMT_ATTR_CURSOR_TYPE; if ($IS_MYSQLND && mysqli_get_client_version() > 50007) $valid_attr["prefetch_rows"] = MYSQLI_STMT_ATTR_PREFETCH_ROWS; do { $invalid_attr = mt_rand(0, 10000); } while (in_array($invalid_attr, $valid_attr)); $stmt = mysqli_stmt_init($link); mysqli_stmt_prepare($stmt, 'SELECT * FROM test'); if (false !== ($tmp = @mysqli_stmt_attr_get($stmt, $invalid_attr))) printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); foreach ($valid_attr as $k => $attr) { if (false === ($tmp = mysqli_stmt_attr_get($stmt, $attr))) { printf("[006] Expecting any type, but not boolean/false, got %s/%s for attribute %s/%s\n", gettype($tmp), $tmp, $k, $attr); } } $stmt->close(); foreach ($valid_attr as $k => $attr) { if (!is_null($tmp = @mysqli_stmt_attr_get($stmt, $attr))) { printf("[007] Expecting NULL/NULL, got %s/%s for attribute %s/%s\n", gettype($tmp), $tmp, $k, $attr); } } mysqli_close($link); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_attr_get_prefetch.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_attr_get_prefetch.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_attr_get_prefetch.phpt --TEST-- mysqli_stmt_attr_get() - prefetch --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> <?php die("SKIP: prefetch isn't supported at the moment") ?> --FILE-- <?php include "connect.inc"; require('table.inc'); $stmt = mysqli_stmt_init($link); mysqli_stmt_prepare($stmt, 'SELECT * FROM test'); if (1 !== ($tmp = mysqli_stmt_attr_get($stmt, MYSQLI_STMT_ATTR_PREFETCH_ROWS))) { printf("[001] Expecting int/1, got %s/%s for attribute %s/%s\n", gettype($tmp), $tmp, $k, $attr); } $stmt->close(); mysqli_close($link); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_attr_set.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_attr_set.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_attr_set.phpt --TEST-- mysqli_stmt_attr_set() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_attr_set())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_attr_set($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_attr_set($link, $link))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_attr_set($link, $link, $link))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); $valid_attr = array(MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH); if (mysqli_get_client_version() > 50003) $valid_attr[] = MYSQLI_STMT_ATTR_CURSOR_TYPE; /* prefetch isn't supported if (mysqli_get_client_version() > 50007) $valid_attr[] = MYSQLI_STMT_ATTR_PREFETCH_ROWS; */ do { $invalid_attr = mt_rand(-10000, 10000); } while (in_array($invalid_attr, $valid_attr)); $stmt = mysqli_stmt_init($link); if (!is_null($tmp = @mysqli_stmt_attr_set($stmt, 0, 0))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); $stmt->prepare("SELECT * FROM test"); if (false !== ($tmp = @mysqli_stmt_attr_set($stmt, $invalid_attr, 0))) printf("[006] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); $stmt->close(); // // MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH // // expecting max_length not to be set and be 0 in all cases $stmt = mysqli_stmt_init($link); $stmt->prepare("SELECT label FROM test"); $stmt->execute(); $stmt->store_result(); $res = $stmt->result_metadata(); $fields = $res->fetch_fields(); $max_lengths = array(); foreach ($fields as $k => $meta) { $max_lengths[$meta->name] = $meta->max_length; if ($meta->max_length !== 0) printf("[007] max_length should be not set (= 0), got %s for field %s\n", $meta->max_length, $meta->name); } $res->close(); $stmt->close(); // expecting max_length to _be_ set $stmt = mysqli_stmt_init($link); $stmt->prepare("SELECT label FROM test"); $stmt->attr_set(MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH, 1); $stmt->execute(); $stmt->store_result(); $res = $stmt->result_metadata(); $fields = $res->fetch_fields(); $max_lengths = array(); foreach ($fields as $k => $meta) { $max_lengths[$meta->name] = $meta->max_length; if ($meta->max_length === 0) printf("[008] max_length should be set (!= 0), got %s for field %s\n", $meta->max_length, $meta->name); } $res->close(); $stmt->close(); // expecting max_length not to be set $stmt = mysqli_stmt_init($link); $stmt->prepare("SELECT label FROM test"); $stmt->attr_set(MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH, 0); $stmt->execute(); $stmt->store_result(); $res = $stmt->result_metadata(); $fields = $res->fetch_fields(); $max_lengths = array(); foreach ($fields as $k => $meta) { $max_lengths[$meta->name] = $meta->max_length; if ($meta->max_length !== 0) printf("[009] max_length should not be set (= 0), got %s for field %s\n", $meta->max_length, $meta->name); } $res->close(); $stmt->close(); // // Cursors // if (mysqli_get_client_version() > 50003) { $cursor_types = array( MYSQLI_CURSOR_TYPE_NO_CURSOR, MYSQLI_CURSOR_TYPE_READ_ONLY, MYSQLI_CURSOR_TYPE_FOR_UPDATE, MYSQLI_CURSOR_TYPE_SCROLLABLE ); do { $invalid_cursor_type = mt_rand(-1000, 1000); } while (in_array($invalid_cursor_type, $cursor_types)); $stmt = mysqli_stmt_init($link); $stmt->prepare("SELECT id, label FROM test"); if (false !== ($tmp = @$stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, $invalid_cursor_type))) printf("[010] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_FOR_UPDATE))) printf("[011] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_SCROLLABLE))) printf("[012] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_NO_CURSOR))) printf("[013] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_READ_ONLY))) printf("[014] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); $stmt->close(); $stmt = mysqli_stmt_init($link); $stmt->prepare("SELECT id, label FROM test"); $stmt->execute(); $id = $label = NULL; $stmt->bind_result($id, $label); $results = array(); while ($stmt->fetch()) $results[$id] = $label; $stmt->close(); if (empty($results)) printf("[015] Results should not be empty, subsequent tests will probably fail!\n"); $stmt = mysqli_stmt_init($link); $stmt->prepare("SELECT id, label FROM test"); if (true !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_NO_CURSOR))) printf("[016] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); $stmt->execute(); $id = $label = NULL; $stmt->bind_result($id, $label); $results2 = array(); while ($stmt->fetch()) $results2[$id] = $label; $stmt->close(); if ($results != $results2) { printf("[017] Results should not differ. Dumping both result sets.\n"); var_dump($results); var_dump($results2); } $stmt = mysqli_stmt_init($link); $stmt->prepare("SELECT id, label FROM test"); if (true !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_READ_ONLY))) printf("[018] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); $stmt->execute(); $id = $label = NULL; $stmt->bind_result($id, $label); $results2 = array(); while ($stmt->fetch()) $results2[$id] = $label; $stmt->close(); if ($results != $results2) { printf("[019] Results should not differ. Dumping both result sets.\n"); var_dump($results); var_dump($results2); } } // // MYSQLI_STMT_ATTR_PREFETCH_ROWS // if (mysqli_get_client_version() > 50007) { $stmt = mysqli_stmt_init($link); $stmt->prepare("SELECT id, label FROM test"); if (true !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_PREFETCH_ROWS, 1))) printf("[020] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); $stmt->execute(); $id = $label = NULL; $stmt->bind_result($id, $label); $results = array(); while ($stmt->fetch()) $results[$id] = $label; $stmt->close(); if (empty($results)) printf("[021] Results should not be empty, subsequent tests will probably fail!\n"); /* prefetch is not supported $stmt = mysqli_stmt_init($link); $stmt->prepare("SELECT label FROM test"); if (false !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_PREFETCH_ROWS, -1))) printf("[022] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); $stmt->close(); $stmt = mysqli_stmt_init($link); $stmt->prepare("SELECT label FROM test"); if (true !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_PREFETCH_ROWS, PHP_INT_MAX))) printf("[023] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); $stmt->close(); $stmt = mysqli_stmt_init($link); $stmt->prepare("SELECT id, label FROM test"); if (true !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_PREFETCH_ROWS, 2))) printf("[024] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); $stmt->execute(); $id = $label = NULL; $stmt->bind_result($id, $label); $results2 = array(); while ($stmt->fetch()) $results2[$id] = $label; $stmt->close(); if ($results != $results2) { printf("[025] Results should not differ. Dumping both result sets.\n"); var_dump($results); var_dump($results2); } */ } mysqli_close($link); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_bind_param.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_bind_param.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_bind_param.phpt --TEST-- mysqli_stmt_bind_param() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php /* The way we test the INSERT and data types overlaps with the mysqli_stmt_bind_result test in large parts. There is only one difference. This test uses mysqli_query()/mysqli_fetch_assoc() to fetch the inserted values. This way we test mysqli_query()/mysqli_fetch_assoc() for all possible data types in this file and we test mysqli_stmt_bind_result() in the other test -- therefore the "duplicate" makes some sense to me. */ include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_bind_param())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_bind_param($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_bind_param($link, $link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) printf("[003] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); $id = null; $label = null; /* libmysql gives a less descriptive error message but mysqlnd, we did not unify the error messages but ignore this slight difference silently */ if (!false === ($tmp = @mysqli_stmt_bind_param($stmt, "", $id, $label))) printf("[003a] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); /* TODO: somehwhat undocumented syntax! */ $param = array($id); if (!false === ($tmp = mysqli_stmt_bind_param($stmt, "is", $param))) printf("[003b] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); $param = array($id, $label, $id); if (!false === ($tmp = mysqli_stmt_bind_param($stmt, "is", $param))) printf("[003c] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (!false === ($tmp = mysqli_stmt_bind_param($stmt, "a", $id))) printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (!false === ($tmp = mysqli_stmt_bind_param($stmt, "a", $id, $label))) printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (!false === ($tmp = mysqli_stmt_bind_param($stmt, "aa", $id, $label))) printf("[006] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (!false === ($tmp = mysqli_stmt_bind_param($stmt, "ia", $id, $label))) printf("[007] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (!true === ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label))) printf("[008] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (function_exists("memory_get_usage")) { $mem = memory_get_usage(); for ($i = 0; $i < 20000; $i++) { if (!true === ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label))) printf("[008][$i] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); } if (($tmp = (memory_get_usage() - $mem)) > 600) printf("[009] Function seems to be leaking, because it used %d bytes. During tests it used only 92 bytes.", $tmp); } $id = 100; $label = "z"; if (!mysqli_stmt_execute($stmt)) printf("[010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); mysqli_stmt_close($stmt); if (!($res = mysqli_query($link, "SELECT id, label FROM test WHERE id = " . $id))) printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $row = mysqli_fetch_assoc($res); if (($row['id'] != $id) || ($row['label'] != $label)) printf("[012] Expecting '%s'/%s', got '%s'/%s'!\n", $id, $label, $row['id'], $row['label']); mysqli_free_result($res); function func_mysqli_stmt_bind_datatype($link, $engine, $bind_type, $sql_type, $bind_value, $offset, $alternative = null) { if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) { printf("[%03d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link)); return false; } if (!mysqli_query($link, sprintf("CREATE TABLE test(id INT NOT NULL, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) { // don't bail - it might be that the server does not support the data type return false; } if (!$stmt = mysqli_stmt_init($link)) { printf("[%03d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link)); return false; } if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUE (?, ?)")) { printf("[%03d] [%d] %s\n", $offset + 2, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); return false; } $id = 1; if (!mysqli_stmt_bind_param($stmt, "i" . $bind_type, $id, $bind_value)) { printf("[%03d] [%d] %s\n", $offset + 3, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); return false; } if (!mysqli_stmt_execute($stmt)) { printf("[%03d] [%d] %s\n", $offset + 4, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); return false; } mysqli_stmt_close($stmt); if (!$res = mysqli_query($link, "SELECT id, label FROM test")) { printf("[%03d] [%d] %s\n", $offset + 5, mysqli_errno($link), mysqli_error($link)); return false; } if (!$row = mysqli_fetch_assoc($res)) { printf("[%03d] [%d] %s\n", $offset + 5, mysqli_errno($link), mysqli_error($link)); return false; } if ($alternative) { if (($row['id'] != $id) || (($row['label'] != $bind_value) && ($row['label'] != $alternative))) { printf("[%03d] Testing '%s', '%s': expecting '%s'/'%s' (%s), got '%s'/'%s'\n", $offset + 6, $bind_type, $sql_type, $id, $bind_value, gettype($bind_value), $row['id'], $row['label']); return false; } } else { if (($row['id'] != $id) || ($row['label'] != $bind_value)) { printf("[%03d] Testing '%s', '%s': expecting '%s'/'%s', got '%s'/'%s'\n", $offset + 6, $bind_type, $sql_type, $id, $bind_value, $row['id'], $row['label']); return false; } } mysqli_free_result($res); return true; } function func_mysqli_stmt_bind_make_string($len) { $ret = ''; for ($i = 0; $i < $len; $i++) $ret .= chr(mt_rand(65, 90)); return $ret; } func_mysqli_stmt_bind_datatype($link, $engine, "i", "TINYINT", -11, 20); func_mysqli_stmt_bind_datatype($link, $engine, "i", "TINYINT", NULL, 30); func_mysqli_stmt_bind_datatype($link, $engine, "i", "TINYINT UNSIGNED", 1, 40); func_mysqli_stmt_bind_datatype($link, $engine, "i", "TINYINT UNSIGNED", NULL, 50); func_mysqli_stmt_bind_datatype($link, $engine, "i", "BOOL", 1, 60); func_mysqli_stmt_bind_datatype($link, $engine, "i", "BOOL", NULL, 70); func_mysqli_stmt_bind_datatype($link, $engine, "i", "BOOLEAN", 0, 80); func_mysqli_stmt_bind_datatype($link, $engine, "i", "BOOLEAN", NULL, 90); func_mysqli_stmt_bind_datatype($link, $engine, "i", "SMALLINT", -32768, 100); func_mysqli_stmt_bind_datatype($link, $engine, "i", "SMALLINT", 32767, 110); func_mysqli_stmt_bind_datatype($link, $engine, "i", "SMALLINT", NULL, 120); func_mysqli_stmt_bind_datatype($link, $engine, "i", "SMALLINT UNSIGNED", 65535, 130); func_mysqli_stmt_bind_datatype($link, $engine, "i", "SMALLINT UNSIGNED", NULL, 140); func_mysqli_stmt_bind_datatype($link, $engine, "i", "MEDIUMINT", -8388608, 150); func_mysqli_stmt_bind_datatype($link, $engine, "i", "MEDIUMINT", 8388607, 160); func_mysqli_stmt_bind_datatype($link, $engine, "i", "MEDIUMINT", NULL, 170); func_mysqli_stmt_bind_datatype($link, $engine, "i", "MEDIUMINT UNSIGNED", 16777215, 180); func_mysqli_stmt_bind_datatype($link, $engine, "i", "MEDIUMINT UNSIGNED", NULL, 190); func_mysqli_stmt_bind_datatype($link, $engine, "i", "INTEGER", -2147483648, 200); func_mysqli_stmt_bind_datatype($link, $engine, "i", "INTEGER", 2147483647, 210); func_mysqli_stmt_bind_datatype($link, $engine, "i", "INTEGER", NULL, 220); func_mysqli_stmt_bind_datatype($link, $engine, "i", "INTEGER UNSIGNED", (defined("PHP_INT_MAX")) ? min(4294967295, PHP_INT_MAX) : 1, 230); func_mysqli_stmt_bind_datatype($link, $engine, "d", "INTEGER UNSIGNED", 4294967295, 240); func_mysqli_stmt_bind_datatype($link, $engine, "i", "INTEGER UNSIGNED", NULL, 250); func_mysqli_stmt_bind_datatype($link, $engine, "i", "BIGINT", -1 * PHP_INT_MAX + 1, 260); func_mysqli_stmt_bind_datatype($link, $engine, "i", "BIGINT", NULL, 270); func_mysqli_stmt_bind_datatype($link, $engine, "i", "BIGINT", PHP_INT_MAX, 280); func_mysqli_stmt_bind_datatype($link, $engine, "i", "BIGINT UNSIGNED", NULL, 290); func_mysqli_stmt_bind_datatype($link, $engine, "s", "BIGINT", "-9223372036854775808", 900); // ?? func_mysqli_stmt_bind_datatype($link, $engine, "d", "BIGINT", -9223372036854775808, 910); func_mysqli_stmt_bind_datatype($link, $engine, "s", "BIGINT UNSIGNED", "18446744073709551615", 920); /* ?? func_mysqli_stmt_bind_datatype($link, $engine, "d", "FLOAT", -9223372036854775808 - 1.1, 300); func_mysqli_stmt_bind_datatype($link, $engine, "d", "FLOAT UNSIGNED", 18446744073709551615 + 1.1, 320); */ func_mysqli_stmt_bind_datatype($link, $engine, "d", "FLOAT", NULL, 310); func_mysqli_stmt_bind_datatype($link, $engine, "d", "FLOAT UNSIGNED ", NULL, 330); if (2147483647 == PHP_INT_MAX) { func_mysqli_stmt_bind_datatype($link, $engine, "d", "FLOAT UNSIGNED", PHP_INT_MAX, 930, '2.14748e+09'); func_mysqli_stmt_bind_datatype($link, $engine, "d", "FLOAT", -1 * PHP_INT_MAX + 1, 940, '-2.14748e+09'); } func_mysqli_stmt_bind_datatype($link, $engine, "s", "FLOAT", "-9223372036854775808", 300, '-9.22337e+18'); func_mysqli_stmt_bind_datatype($link, $engine, "s", "FLOAT UNSIGNED", "18446744073709551615", 320, '1.84467e+19'); func_mysqli_stmt_bind_datatype($link, $engine, "d", "FLOAT", -10.01, 950); func_mysqli_stmt_bind_datatype($link, $engine, "d", "FLOAT UNSIGNED", 10.01, 960); func_mysqli_stmt_bind_datatype($link, $engine, "d", "DOUBLE(10,2)", NULL, 350); func_mysqli_stmt_bind_datatype($link, $engine, "d", "DOUBLE(10,2) UNSIGNED", NULL, 370); func_mysqli_stmt_bind_datatype($link, $engine, "d", "DOUBLE(10,2)", -99999999.99, 340); func_mysqli_stmt_bind_datatype($link, $engine, "d", "DOUBLE(10,2) UNSIGNED", 99999999.99, 360); /* func_mysqli_stmt_bind_datatype($link, $engine, "d", "DOUBLE(10,2)", -99999999.99, 340); func_mysqli_stmt_bind_datatype($link, $engine, "d", "DOUBLE(10,2) UNSIGNED", 99999999.99, 360); */ func_mysqli_stmt_bind_datatype($link, $engine, "d", "DECIMAL(10,2)", -99999999.99, 380); func_mysqli_stmt_bind_datatype($link, $engine, "d", "DECIMAL(10,2)", NULL, 390); func_mysqli_stmt_bind_datatype($link, $engine, "d", "DECIMAL(10,2)", 99999999.99, 400); func_mysqli_stmt_bind_datatype($link, $engine, "d", "DECIMAL(10,2)", NULL, 410); // don't care about date() strict TZ warnings... func_mysqli_stmt_bind_datatype($link, $engine, "s", "DATE", @date('Y-m-d'), 420); func_mysqli_stmt_bind_datatype($link, $engine, "s", "DATE NOT NULL", @date('Y-m-d'), 430); func_mysqli_stmt_bind_datatype($link, $engine, "s", "DATE", NULL, 440); func_mysqli_stmt_bind_datatype($link, $engine, "s", "DATETIME", @date('Y-m-d H:i:s'), 450); func_mysqli_stmt_bind_datatype($link, $engine, "s", "DATETIME NOT NULL", @date('Y-m-d H:i:s'), 460); func_mysqli_stmt_bind_datatype($link, $engine, "s", "DATETIME", NULL, 470); func_mysqli_stmt_bind_datatype($link, $engine, "s", "TIMESTAMP", @date('Y-m-d H:i:s'), 480); func_mysqli_stmt_bind_datatype($link, $engine, "s", "TIME", @date('H:i:s'), 490); func_mysqli_stmt_bind_datatype($link, $engine, "s", "TIME NOT NULL", @date('H:i:s'), 500); func_mysqli_stmt_bind_datatype($link, $engine, "s", "TIME", NULL, 510); func_mysqli_stmt_bind_datatype($link, $engine, "s", "YEAR", @date('Y'), 520); func_mysqli_stmt_bind_datatype($link, $engine, "s", "YEAR NOT NULL", @date('Y'), 530); func_mysqli_stmt_bind_datatype($link, $engine, "s", "YEAR", NULL, 540); $string255 = func_mysqli_stmt_bind_make_string(255); func_mysqli_stmt_bind_datatype($link, $engine, "s", "CHAR(1)", "a", 550); func_mysqli_stmt_bind_datatype($link, $engine, "s", "CHAR(255)", $string255, 560); func_mysqli_stmt_bind_datatype($link, $engine, "s", "CHAR(1) NOT NULL", "a", 570); func_mysqli_stmt_bind_datatype($link, $engine, "s", "CHAR(1)", NULL, 580); $string65k = func_mysqli_stmt_bind_make_string(65535); func_mysqli_stmt_bind_datatype($link, $engine, "s", "VARCHAR(1)", "a", 590); func_mysqli_stmt_bind_datatype($link, $engine, "s", "VARCHAR(255)", $string255, 600); func_mysqli_stmt_bind_datatype($link, $engine, "s", "VARCHAR(65635)", $string65k, 610); func_mysqli_stmt_bind_datatype($link, $engine, "s", "VARCHAR(1) NOT NULL", "a", 620); func_mysqli_stmt_bind_datatype($link, $engine, "s", "VARCHAR(1)", NULL, 630); func_mysqli_stmt_bind_datatype($link, $engine, "s", "BINARY(1)", "a", 640); func_mysqli_stmt_bind_datatype($link, $engine, "s", "BINARY(1)", chr(0), 650); func_mysqli_stmt_bind_datatype($link, $engine, "s", "BINARY(1) NOT NULL", "b", 660); func_mysqli_stmt_bind_datatype($link, $engine, "s", "BINARY(1)", NULL, 670); func_mysqli_stmt_bind_datatype($link, $engine, "s", "VARBINARY(1)", "a", 680); func_mysqli_stmt_bind_datatype($link, $engine, "s", "VARBINARY(1)", chr(0), 690); func_mysqli_stmt_bind_datatype($link, $engine, "s", "VARBINARY(1) NOT NULL", "b", 700); func_mysqli_stmt_bind_datatype($link, $engine, "s", "VARBINARY(1)", NULL, 710); func_mysqli_stmt_bind_datatype($link, $engine, "s", "TINYBLOB", "a", 720); func_mysqli_stmt_bind_datatype($link, $engine, "s", "TINYBLOB", chr(0), 730); func_mysqli_stmt_bind_datatype($link, $engine, "s", "TINYBLOB NOT NULL", "b", 740); func_mysqli_stmt_bind_datatype($link, $engine, "s", "TINYBLOB", NULL, 750); func_mysqli_stmt_bind_datatype($link, $engine, "s", "TINYTEXT", "a", 760); func_mysqli_stmt_bind_datatype($link, $engine, "s", "TINYTEXT NOT NULL", "a", 770); func_mysqli_stmt_bind_datatype($link, $engine, "s", "TINYTEXT", NULL, 780); // Note: you cannot insert any blob values this way. But you can check the API at least partly this way // Extra BLOB tests are in mysqli_stmt_send_long() func_mysqli_stmt_bind_datatype($link, $engine, "b", "BLOB", "", 790); func_mysqli_stmt_bind_datatype($link, $engine, "b", "TEXT", "", 800); func_mysqli_stmt_bind_datatype($link, $engine, "b", "MEDIUMBLOB", "", 810); func_mysqli_stmt_bind_datatype($link, $engine, "b", "MEDIUMTEXT", "", 820); func_mysqli_stmt_bind_datatype($link, $engine, "b", "LONGBLOB", "", 830); func_mysqli_stmt_bind_datatype($link, $engine, "b", "LONGTEXT", "", 840); func_mysqli_stmt_bind_datatype($link, $engine, "s", "ENUM('a', 'b')", "a", 850); func_mysqli_stmt_bind_datatype($link, $engine, "s", "ENUM('a', 'b')", NULL, 860); func_mysqli_stmt_bind_datatype($link, $engine, "s", "SET('a', 'b')", "a", 870); func_mysqli_stmt_bind_datatype($link, $engine, "s", "SET('a', 'b')", NULL, 880); $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) printf("[2000] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); $id = null; $label = null; if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label))) printf("[2001] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); mysqli_stmt_execute($stmt); if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label))) printf("[2002] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); mysqli_stmt_close($stmt); include("table.inc"); if (!$stmt = mysqli_stmt_init($link)) printf("[2003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) printf("[2004] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); $id = $label = null; if (true !== ($tmp = $stmt->bind_param('is', $id, $label))) printf("[2005] Expecting boolean/true got %s/%s, [%d] %s\n", gettype($tmp), $tmp, $stmt->errno, $stmt->error); $id = 100; $label = 'z'; if (!$stmt->execute()) printf("[2006] [%d] %s\n", $stmt->errno, $stmt->error); if (!$res = mysqli_query($link, "SELECT id, label FROM test WHERE id = 100")) printf("[2007] Expecting record 100/z, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$row = mysqli_fetch_assoc($res)) printf("[2008] Expecting row, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if ($row['id'] != 100 || $row['label'] != 'z') { printf("[2009] Row seems wrong, dumping record\n"); var_dump($row); } mysqli_free_result($res); mysqli_stmt_close($stmt); mysqli_close($link); /* Check that the function alias exists. It's a deprecated function, but we have not announce the removal so far, therefore we need to check for it */ if (!is_null($tmp = @mysqli_bind_param())) printf("[021] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_stmt_bind_param(): Number of elements in type definition string doesn't match number of bind variables in %s on line %d Warning: mysqli_stmt_bind_param(): Number of elements in type definition string doesn't match number of bind variables in %s on line %d Warning: mysqli_stmt_bind_param(): Number of variables doesn't match number of parameters in prepared statement in %s on line %d Warning: mysqli_stmt_bind_param(): Number of elements in type definition string doesn't match number of bind variables in %s on line %d Warning: mysqli_stmt_bind_param(): Undefined fieldtype a (parameter 3) in %s on line %d Warning: mysqli_stmt_bind_param(): Undefined fieldtype a (parameter 4) in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_bind_param_references.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_bind_param_references.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_bind_param_references.phpt --TEST-- mysqli_stmt_bind_param() - playing with references --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; require('table.inc'); function findRow($offset, $link, $id, $label) { $sql = sprintf("SELECT id, label FROM test WHERE id = '%d' AND label = '%s'", $id, $label); if (!$res = mysqli_query($link, $sql)) { printf("[%03d + 1] %s failed, [%d] %s\n", $offset, $sql, mysqli_errno($link), mysqli_error($link)); return false; } if (!$row = mysqli_fetch_assoc($res)) { printf("[%03d + 2] fetch for %s failed, [%d] %s\n", $offset, $sql, mysqli_errno($link), mysqli_error($link)); return false; } mysqli_free_result($res); if ($row['id'] != $id) { printf("[%03d + 3] Expecting %s/%s got %s/%s\n", $offset, gettype($id), $id, gettype($row['id']), $row['id'] ); return false; } if ($row['label'] != $label) { printf("[%03d + 4] Expecting %s/%s got %s/%s\n", $offset, gettype($label), $label, gettype($row['label']), $row['label'] ); return false; } $sql = sprintf("DELETE FROM test WHERE id = '%d' AND label = '%s'", $id, $label); if (!mysqli_query($link, $sql)) { printf("[%03d + 5] %s failed, [%d] %s\n", $offset, $sql, mysqli_errno($link), mysqli_error($link)); return false; } return true; } // or we will get dups around [28] mysqli_query($link, "ALTER TABLE test DROP PRIMARY KEY"); $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) printf("[001] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); $id = 100; $label = 'v'; if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label))) printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (true !== mysqli_stmt_execute($stmt)) printf("[003] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); // no need to check the return value, will bail and make EXPECTF fail if need be findRow(4, $link, $id, $label); $id++; $label_ref = &$label; $label = 'w'; if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label_ref))) printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (true !== mysqli_stmt_execute($stmt)) printf("[006] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); findRow(7, $link, $id, $label_ref); $id++; $label_ref_ref = &$label_ref; $label = 'x'; if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label_ref_ref))) printf("[007] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (true !== mysqli_stmt_execute($stmt)) printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); findRow(9, $link, $id, $label_ref_ref); $id = 9; $label = $id; $label_num = &$label; if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label_num))) printf("[010] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (true !== mysqli_stmt_execute($stmt)) printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); findRow(12, $link, $id, $label_num); $label_num = &$id; if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label_num))) printf("[013] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (true !== mysqli_stmt_execute($stmt)) printf("[014] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); findRow(15, $link, $id, $label_num); $label = 9; $id = &$label; if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label))) printf("[015] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (true !== mysqli_stmt_execute($stmt)) printf("[016] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); findRow(17, $link, $id, $label); $base = 9; $id = &$base; $label = &$id; if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label))) printf("[018] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (true !== mysqli_stmt_execute($stmt)) printf("[019] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); findRow(20, $link, $id, $label); $id_ref = &$id; $label_ref = &$label; if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id_ref, $label_ref))) printf("[021] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (true !== mysqli_stmt_execute($stmt)) printf("[022] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); findRow(23, $link, $id_ref, $label_ref); $id_ref_ref = &$GLOBALS['id_ref']; $label_ref_ref = &$GLOBALS['label_ref_ref']; if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id_ref_ref, $label_ref_ref))) printf("[024] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (true !== mysqli_stmt_execute($stmt)) printf("[025] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); findRow(26, $link, $id_ref_ref, $label_ref_ref); $id = 102; $label = new stdClass(); $label->label = 'y'; $id_ref = &$GLOBALS['id']; $label_ref = &$label->label; if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id_ref, $label_ref))) printf("[027] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (true !== @mysqli_stmt_execute($stmt)) printf("[028] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); findRow(29, $link, $id_ref, $label_ref); $id = 103; $label_a = &$label_b; $label_b = &$label_a; $label_a = 'z'; if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label_b))) printf("[030] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (true !== mysqli_stmt_execute($stmt)) printf("[031] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); findRow(32, $link, $id, $label_b); class foo { public $foo; function foo() { $this->foo = &$this->bar; } } class bar extends foo { public $bar = 'v'; } $bar = new bar(); $id++; $label = &$GLOBALS['bar']->foo; if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label))) printf("[033] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (true !== mysqli_stmt_execute($stmt)) printf("[034] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); findRow(35, $link, $id, $label); mysqli_stmt_close($stmt); mysqli_close($link); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_bind_param_type_juggling.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_bind_param_type_juggling.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_bind_param_type_juggling.phpt --TEST-- mysqli_stmt_bind_param() - binding variable twice --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; require('table.inc'); function bind_twice($link, $engine, $sql_type1, $sql_type2, $bind_type1, $bind_type2, $bind_value1, $bind_value2, $offset) { if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) { printf("[%03d + 1] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link)); return false; } mysqli_autocommit($link, true); $sql = sprintf("CREATE TABLE test(col1 %s, col2 %s) ENGINE=%s", $sql_type1, $sql_type2, $engine); if (!mysqli_query($link, $sql)) { printf("[%03d + 2] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link)); return false; } if (!$stmt = mysqli_stmt_init($link)) { printf("[%03d + 3] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link)); return false; } if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(col1, col2) VALUES (?, ?)")) { printf("[%03d + 4] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); return false; } if (!mysqli_stmt_bind_param($stmt, $bind_type1 . $bind_type2, $bind_value1, $bind_value1)) { printf("[%03d + 5] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); return false; } if (!mysqli_stmt_execute($stmt)) { printf("[%03d + 6] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); return false; } if (!mysqli_stmt_bind_param($stmt, $bind_type1 . $bind_type2, $bind_value1, $bind_value2)) { printf("[%03d + 7] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); return false; } if (!mysqli_stmt_execute($stmt)) { printf("[%03d + 8] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); return false; } mysqli_stmt_close($stmt); if (!$res = mysqli_query($link, "SELECT col1, col2 FROM test")) { printf("[%03d + 9] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link)); return false; } if (2 !== ($tmp = mysqli_num_rows($res))) { printf("[%03d + 10] Expecting 2 rows, got %d rows [%d] %s\n", $offset, $tmp, mysqli_errno($link), mysqli_error($link)); } $row = mysqli_fetch_assoc($res); if (($row['col1'] != $bind_value1) || ($row['col2'] != $bind_value1)) { printf("[%03d + 11] Expecting col1 = %s, col2 = %s got col1 = %s, col2 = %s - [%d] %s\n", $offset, $bind_value1, $bind_value1, $row['col1'], $row['col2'], mysqli_errno($link), mysqli_error($link)); return false; } $row = mysqli_fetch_assoc($res); if (($row['col1'] != $bind_value1) || ($row['col2'] != $bind_value2)) { printf("[%03d + 12] Expecting col1 = %s, col2 = %s got col1 = %s, col2 = %s - [%d] %s\n", $offset, $bind_value1, $bind_value2, $row['col1'], $row['col2'], mysqli_errno($link), mysqli_error($link)); return false; } mysqli_free_result($res); return true; } bind_twice($link, $engine, 'CHAR(1)', 'CHAR(1)', 's', 's', 'a', 'b', 10); bind_twice($link, $engine, 'INT', 'INT', 'i', 'i', 1, 2, 20); bind_twice($link, $engine, 'FLOAT', 'FLOAT', 'd', 'd', 1.01, 1.02, 30); /* type juggling - note that int->char works */ bind_twice($link, $engine, 'CHAR(1)', 'CHAR(1)', 's', 's', 1, 2, 40); /* type juggling - note that string->integer works */ bind_twice($link, $engine, 'INT', 'INT', 'i', 'i', '1', '2', 50); /* type juggling - note that string->float works*/ bind_twice($link, $engine, 'FLOAT', 'FLOAT', 'd', 'd', '1.01', '1.02', 60); /* now, let's have two columns of different type and do type juggling */ /* what the test will do is: 1) col1 INT, col2 CHAR(1) 2) bind_param('is', 1, 1) 3) execute() 4) bind_param('is', 1, 'a') 5) execute() col1 INT, col2 INT bind_param('ii', '1', '2') --> OK (int column, string value) bind_param('ii', 1, 2) --> OK (int column, int value) col1 CHAR(1), col2 CHAR(2) bind_param('ss', 1, 2) --> OK (string column, int value) So, what about: col1 INT, COL2 CHAR(1) bind_param('is', 1, 1) ---> ?? */ bind_twice($link, $engine, 'INT', 'CHAR(1)', 'i', 's', 1, 'a', 70); mysqli_close($link); print "done!"; ?> --EXPECTF-- done! --UEXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_bind_result.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_bind_result.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_bind_result.phpt --TEST-- mysqli_stmt_bind_result() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $hint_str_or_unicode = ini_get("unicode.semantics")? "unicode":"string"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_bind_result())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_bind_result($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 1")) printf("[002a] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!is_null($tmp = @mysqli_stmt_bind_result($stmt))) printf("[002b] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); $stmt = mysqli_stmt_init($link); $id = null; $label = null; $foo = null; if (!is_null($tmp = mysqli_stmt_bind_result($stmt))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 1")) printf("[004] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (false !== ($tmp = mysqli_stmt_bind_result($stmt, $id))) printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label))) printf("[006] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label, $foo))) printf("[007] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_execute($stmt)) printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); while (mysqli_stmt_fetch($stmt)) { var_dump($id); var_dump($label); } mysqli_stmt_close($stmt); function func_mysqli_stmt_bind_result($link, $engine, $bind_type, $sql_type, $bind_value, $offset, $type_hint = null) { if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) { printf("[%04d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link)); return false; } if (!mysqli_query($link, sprintf("CREATE TABLE test(id INT, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) { // don't bail - column type might not be supported by the server, ignore this return false; } if (!$stmt = mysqli_stmt_init($link)) { printf("[%04d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link)); return false; } if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) { printf("[%04d] [%d] %s\n", $offset + 2, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); return false; } $id = null; if (!mysqli_stmt_bind_param($stmt, "i" . $bind_type, $id, $bind_value)) { printf("[%04d] [%d] %s\n", $offset + 3, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); mysqli_stmt_close($stmt); return false; } for ($id = 1; $id < 4; $id++) { if (!mysqli_stmt_execute($stmt)) { printf("[%04d] [%d] %s\n", $offset + 3 + $id, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); mysqli_stmt_close($stmt); return false; } } mysqli_stmt_close($stmt); $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test")) { printf("[%04d] [%d] %s\n", $offset + 7, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); mysqli_stmt_close($stmt); return false; } if (!mysqli_stmt_execute($stmt)) { printf("[%04d] [%d] %s\n", $offset + 8, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); mysqli_stmt_close($stmt); return false; } $result = mysqli_stmt_result_metadata($stmt); $bind_res = null; if (!mysqli_stmt_bind_result($stmt, $id, $bind_res)) { printf("[%04d] [%d] %s\n", $offset + 9, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); mysqli_stmt_close($stmt); return false; } $num = 0; $fields = mysqli_fetch_fields($result); while (mysqli_stmt_fetch($stmt)) { if (!gettype($bind_res)=="unicode") { if ($bind_res !== $bind_value && (!$type_hint || ($type_hint !== gettype($bind_res)))) { printf("[%04d] [%d] Expecting %s/'%s' [type hint = %s], got %s/'%s'\n", $offset + 10, $num, gettype($bind_value), $bind_value, $type_hint, gettype($bind_res), $bind_res); mysqli_stmt_close($stmt); return false; } } $num++; } if ($num != 3) { printf("[%04d] [%d] %s, expecting 3 results, got only %d results\n", $offset + 11, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), $num); mysqli_stmt_close($stmt); return false; } mysqli_stmt_close($stmt); return true; } function func_mysqli_stmt_bind_make_string($len) { $ret = ''; for ($i = 0; $i < $len; $i++) $ret .= chr(mt_rand(65, 90)); return $ret; } func_mysqli_stmt_bind_result($link, $engine, "i", "TINYINT", -11, 20); func_mysqli_stmt_bind_result($link, $engine, "i", "TINYINT", NULL, 40); func_mysqli_stmt_bind_result($link, $engine, "i", "TINYINT UNSIGNED", 1, 60); func_mysqli_stmt_bind_result($link, $engine, "i", "TINYINT UNSIGNED", NULL, 80); func_mysqli_stmt_bind_result($link, $engine, "i", "BOOL", 1, 100); func_mysqli_stmt_bind_result($link, $engine, "i", "BOOL", NULL, 120); func_mysqli_stmt_bind_result($link, $engine, "i", "BOOLEAN", 0, 140); func_mysqli_stmt_bind_result($link, $engine, "i", "BOOLEAN", NULL, 160); func_mysqli_stmt_bind_result($link, $engine, "i", "SMALLINT", -32768, 180); func_mysqli_stmt_bind_result($link, $engine, "i", "SMALLINT", 32767, 200); func_mysqli_stmt_bind_result($link, $engine, "i", "SMALLINT", NULL, 220); func_mysqli_stmt_bind_result($link, $engine, "i", "SMALLINT UNSIGNED", 65535, 240); func_mysqli_stmt_bind_result($link, $engine, "i", "SMALLINT UNSIGNED", NULL, 260); func_mysqli_stmt_bind_result($link, $engine, "d", "MEDIUMINT", -8388608, 280, "integer"); func_mysqli_stmt_bind_result($link, $engine, "d", "MEDIUMINT", 8388607, 300, "integer"); func_mysqli_stmt_bind_result($link, $engine, "d", "MEDIUMINT", NULL, 320); func_mysqli_stmt_bind_result($link, $engine, "d", "MEDIUMINT UNSIGNED", 16777215, 340, "integer"); func_mysqli_stmt_bind_result($link, $engine, "d", "MEDIUMINT UNSIGNED", NULL, 360); func_mysqli_stmt_bind_result($link, $engine, "i", "INTEGER", (defined("PHP_INT_MAX")) ? max(-1 * PHP_INT_MAX + 1, -2147483648) : 1, 380); func_mysqli_stmt_bind_result($link, $engine, "i", "INTEGER", -2147483647, 400, "integer"); func_mysqli_stmt_bind_result($link, $engine, "i", "INTEGER", (defined("PHP_INT_MAX")) ? min(2147483647, PHP_INT_MAX) : 1, 420); func_mysqli_stmt_bind_result($link, $engine, "i", "INTEGER", NULL, 440); func_mysqli_stmt_bind_result($link, $engine, "i", "INTEGER UNSIGNED", (defined("PHP_INT_MAX")) ? min(4294967295, 2147483647) : 1, 460); func_mysqli_stmt_bind_result($link, $engine, "i", "INTEGER UNSIGNED", 4294967295, 480, (defined("PHP_INT_MAX") && (4294967295 > PHP_INT_MAX)) ? "string" : null); func_mysqli_stmt_bind_result($link, $engine, "i", "INTEGER UNSIGNED", NULL, 500); /* test is broken too: we bind "integer" but value is a float func_mysqli_stmt_bind_result($link, $engine, "i", "BIGINT", -9223372036854775808, 520); func_mysqli_stmt_bind_result($link, $engine, "i", "BIGINT UNSIGNED", 18446744073709551615, 560); */ func_mysqli_stmt_bind_result($link, $engine, "i", "BIGINT", NULL, 540); func_mysqli_stmt_bind_result($link, $engine, "i", "BIGINT UNSIGNED", NULL, 580); func_mysqli_stmt_bind_result($link, $engine, "i", "BIGINT", -1, 1780); func_mysqli_stmt_bind_result($link, $engine, "i", "BIGINT UNSIGNED", 1, 1800); func_mysqli_stmt_bind_result($link, $engine, "i", "BIGINT", -1 * PHP_INT_MAX + 1, 1820); func_mysqli_stmt_bind_result($link, $engine, "i", "BIGINT UNSIGNED", PHP_INT_MAX, 1840); func_mysqli_stmt_bind_result($link, $engine, "s", "BIGINT UNSIGNED", "18446744073709551615", 1860); func_mysqli_stmt_bind_result($link, $engine, "s", "BIGINT", "-9223372036854775808", 1880); func_mysqli_stmt_bind_result($link, $engine, "d", "FLOAT", -9223372036854775808 - 1.1, 600); func_mysqli_stmt_bind_result($link, $engine, "d", "FLOAT", NULL, 620); func_mysqli_stmt_bind_result($link, $engine, "d", "FLOAT UNSIGNED", 18446744073709551615 + 1.1, 640); func_mysqli_stmt_bind_result($link, $engine, "d", "FLOAT UNSIGNED ", NULL, 660); // Yes, we need the temporary variable. The PHP casting will fouls us otherwise. $tmp = strval('-99999999.99'); func_mysqli_stmt_bind_result($link, $engine, "d", "DOUBLE(10,2)", $tmp, 680, "string"); func_mysqli_stmt_bind_result($link, $engine, "d", "DOUBLE(10,2)", NULL, 700); $tmp = strval('99999999.99'); func_mysqli_stmt_bind_result($link, $engine, "d", "DOUBLE(10,2) UNSIGNED", $tmp , 720, "string"); func_mysqli_stmt_bind_result($link, $engine, "d", "DOUBLE(10,2) UNSIGNED", NULL, 740); $tmp = strval('-99999999.99'); func_mysqli_stmt_bind_result($link, $engine, "d", "DECIMAL(10,2)", $tmp, 760, "string"); func_mysqli_stmt_bind_result($link, $engine, "d", "DECIMAL(10,2)", NULL, 780); $tmp = strval('99999999.99'); func_mysqli_stmt_bind_result($link, $engine, "d", "DECIMAL(10,2)", $tmp, 800, "string"); func_mysqli_stmt_bind_result($link, $engine, "d", "DECIMAL(10,2)", NULL, 820); // don't care about date() strict TZ warnings... func_mysqli_stmt_bind_result($link, $engine, "s", "DATE", @date('Y-m-d'), 840); func_mysqli_stmt_bind_result($link, $engine, "s", "DATE NOT NULL", @date('Y-m-d'), 860); func_mysqli_stmt_bind_result($link, $engine, "s", "DATE", NULL, 880); func_mysqli_stmt_bind_result($link, $engine, "s", "DATETIME", @date('Y-m-d H:i:s'), 900); func_mysqli_stmt_bind_result($link, $engine, "s", "DATETIME NOT NULL", @date('Y-m-d H:i:s'), 920); func_mysqli_stmt_bind_result($link, $engine, "s", "DATETIME", NULL, 940); func_mysqli_stmt_bind_result($link, $engine, "s", "TIMESTAMP", @date('Y-m-d H:i:s'), 960); func_mysqli_stmt_bind_result($link, $engine, "s", "TIME", @date('H:i:s'), 980); func_mysqli_stmt_bind_result($link, $engine, "s", "TIME NOT NULL", @date('H:i:s'), 1000); func_mysqli_stmt_bind_result($link, $engine, "s", "TIME", NULL, 1020); $tmp = intval(@date('Y')); func_mysqli_stmt_bind_result($link, $engine, "s", "YEAR", $tmp, 1040, "integer"); func_mysqli_stmt_bind_result($link, $engine, "s", "YEAR NOT NULL", $tmp, 1060, "integer"); func_mysqli_stmt_bind_result($link, $engine, "s", "YEAR", NULL, 1080); $string255 = func_mysqli_stmt_bind_make_string(255); func_mysqli_stmt_bind_result($link, $engine, "s", "CHAR(1)", "a", 1110, $hint_str_or_unicode); func_mysqli_stmt_bind_result($link, $engine, "s", "CHAR(255)", $string255, 1120, $hint_str_or_unicode); func_mysqli_stmt_bind_result($link, $engine, "s", "CHAR(1) NOT NULL", "a", 1140, $hint_str_or_unicode); func_mysqli_stmt_bind_result($link, $engine, "s", "CHAR(1)", NULL, 1160); $string65k = func_mysqli_stmt_bind_make_string(65535); func_mysqli_stmt_bind_result($link, $engine, "s", "VARCHAR(1)", "a", 1180, $hint_str_or_unicode); func_mysqli_stmt_bind_result($link, $engine, "s", "VARCHAR(255)", $string255, 1200, $hint_str_or_unicode); func_mysqli_stmt_bind_result($link, $engine, "s", "VARCHAR(65635)", $string65k, 1220, $hint_str_or_unicode); func_mysqli_stmt_bind_result($link, $engine, "s", "VARCHAR(1) NOT NULL", "a", 1240, $hint_str_or_unicode); func_mysqli_stmt_bind_result($link, $engine, "s", "VARCHAR(1)", NULL, 1260); func_mysqli_stmt_bind_result($link, $engine, "s", "BINARY(1)", "a", 1280); func_mysqli_stmt_bind_result($link, $engine, "s", "BINARY(1)", chr(0), 1300); func_mysqli_stmt_bind_result($link, $engine, "s", "BINARY(1) NOT NULL", "b", 1320); func_mysqli_stmt_bind_result($link, $engine, "s", "BINARY(1)", NULL, 1340); func_mysqli_stmt_bind_result($link, $engine, "s", "VARBINARY(1)", "a", 1360); func_mysqli_stmt_bind_result($link, $engine, "s", "VARBINARY(1)", chr(0), 1380); func_mysqli_stmt_bind_result($link, $engine, "s", "VARBINARY(1) NOT NULL", "b", 1400); func_mysqli_stmt_bind_result($link, $engine, "s", "VARBINARY(1)", NULL, 1420); func_mysqli_stmt_bind_result($link, $engine, "s", "TINYBLOB", "a", 1440); func_mysqli_stmt_bind_result($link, $engine, "s", "TINYBLOB", chr(0), 1460); func_mysqli_stmt_bind_result($link, $engine, "s", "TINYBLOB NOT NULL", "b", 1480); func_mysqli_stmt_bind_result($link, $engine, "s", "TINYBLOB", NULL, 1500); func_mysqli_stmt_bind_result($link, $engine, "s", "TINYTEXT", "a", 1520, $hint_str_or_unicode); func_mysqli_stmt_bind_result($link, $engine, "s", "TINYTEXT NOT NULL", "a", 1540, $hint_str_or_unicode); func_mysqli_stmt_bind_result($link, $engine, "s", "TINYTEXT", NULL, 1560, $hint_str_or_unicode); // Note: you cannot insert any blob values this way. But you can check the API at least partly this way // Extra BLOB tests are in mysqli_stmt_send_long() func_mysqli_stmt_bind_result($link, $engine, "b", "BLOB", b"", 1580); func_mysqli_stmt_bind_result($link, $engine, "b", "TEXT", "", 1600, $hint_str_or_unicode); func_mysqli_stmt_bind_result($link, $engine, "b", "MEDIUMBLOB", b"", 1620); func_mysqli_stmt_bind_result($link, $engine, "b", "MEDIUMTEXT", "", 1640, $hint_str_or_unicode); /* Is this one related? http://bugs.php.net/bug.php?id=35759 */ func_mysqli_stmt_bind_result($link, $engine, "b", "LONGBLOB", "", 1660); func_mysqli_stmt_bind_result($link, $engine, "b", "LONGTEXT", "", 1680, $hint_str_or_unicode); func_mysqli_stmt_bind_result($link, $engine, "s", "ENUM('a', 'b')", "a", 1700, $hint_str_or_unicode); func_mysqli_stmt_bind_result($link, $engine, "s", "ENUM('a', 'b')", NULL, 1720, $hint_str_or_unicode); func_mysqli_stmt_bind_result($link, $engine, "s", "SET('a', 'b')", "a", 1740, $hint_str_or_unicode); func_mysqli_stmt_bind_result($link, $engine, "s", "SET('a', 'b')", NULL, 1760, $hint_str_or_unicode); /* Check that the function alias exists. It's a deprecated function, but we have not announce the removal so far, therefore we need to check for it */ if (!is_null($tmp = @mysqli_bind_result())) printf("[3000] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); print "done!"; ?> --EXPECTF-- Warning: mysqli_stmt_bind_result(): invalid object or resource mysqli_stmt in %s on line %d Warning: mysqli_stmt_bind_result(): Number of bind variables doesn't match number of fields in prepared statement in %s on line %d Warning: mysqli_stmt_bind_result(): Number of bind variables doesn't match number of fields in prepared statement in %s on line %d int(1) %s(1) "a" done! --UEXPECTF-- Warning: mysqli_stmt_bind_result(): invalid object or resource mysqli_stmt in %s on line %d Warning: mysqli_stmt_bind_result(): Number of bind variables doesn't match number of fields in prepared statement in %s on line %d Warning: mysqli_stmt_bind_result(): Number of bind variables doesn't match number of fields in prepared statement in %s on line %d int(1) unicode(1) "a" done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_bind_result_bit.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_bind_result_bit.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_bind_result_bit.phpt --TEST-- mysqli_stmt_bind_result() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; function dec32bin($dec, $bits) { $maxval = pow(2, $bits); $bin = ''; for ($bitval = $maxval; $bitval >= 1; $bitval = $bitval / 2) { if (($dec / $bitval) >= 1) { $bin .= '1'; $dec -= $bitval; } else { $bin .= '0'; } } return $bin; } if (!$link_ins = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (!$link_sel = mysqli_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); for ($bits = 1; $bits <= 46; $bits++) { if (1 == $bits) $max_value = 1; else $max_value = pow(2, $bits) - 1; if (!mysqli_query($link_ins, "DROP TABLE IF EXISTS test")) { printf("[003 - %d] [%d] %s\n", $bits, mysqli_errno($link_ins), mysqli_error($link_ins)); } if (!mysqli_query($link_ins, sprintf("CREATE TABLE test(id BIGINT, bit_value BIT(%d) NOT NULL, bit_null BIT(%d) DEFAULT NULL) ENGINE = %s", $bits, $bits, $engine))) { // don't bail - column type might not be supported by the server, ignore this continue; } if (!$stmt_ins = mysqli_stmt_init($link_ins)) { printf("[004 - %d] [%d] %s\n", $bits, mysqli_errno($link_ins), mysqli_error($link_ins)); continue; } if (!mysqli_stmt_prepare($stmt_ins, "INSERT INTO test(id, bit_value) VALUES (?, ?)")) { printf("[005 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt_ins), mysqli_stmt_error($stmt_ins)); mysqli_stmt_close($stmt_ins); continue; } if (!($stmt_sel = mysqli_stmt_init($link_sel))) { printf("[006 - %d] [%d] %s\n", $bits, mysqli_errno($link_sel), mysqli_error($link_sel)); mysqli_stmt_close($stmt_ins); continue; } $tests = 0; $rand_max = mt_getrandmax(); while ($tests < 10) { $tests++; if (1 == $tests) $value = 0; else if (2 == $tests) $value = $max_value; else { if ($max_value > $rand_max) { $max_loops = floor($max_value/$rand_max); $num_loops = mt_rand(1, $max_loops); $value = 0; for ($i = 0; $i < $num_loops; $i++) $value += mt_rand(0, $rand_max); } else { $value = mt_rand(0, $max_value); } } $bin = ($bits < 32) ? decbin($value) : dec32bin($value, $bits); for ($i = 0; ($i < strlen($bin)) && ($bin[$i] == '0'); $i++) ; $bin2 = substr($bin, $i, strlen($bin)); if (!mysqli_stmt_bind_param($stmt_ins, "dd", $value, $value)) { printf("[007 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt_ins), mysqli_stmt_error($stmt_ins)); mysqli_stmt_close($stmt_ins); continue; } if (!mysqli_stmt_execute($stmt_ins)) { printf("[008 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt_ins), mysqli_stmt_error($stmt_ins)); break; } $sql = sprintf("SELECT id, BIN(bit_value) AS _bin, bit_value, bit_value + 0 AS _bit_value0, bit_null FROM test WHERE id = %d", $value); if ((!mysqli_stmt_prepare($stmt_sel, $sql)) || (!mysqli_stmt_execute($stmt_sel))) { printf("[009 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt_sel), mysqli_stmt_error($stmt_sel)); break; } $row = array('id' => -1, '_bin' => - 1, 'bit_value' => -1, '_bit_value0' => -1, 'bit_null' => -1); if (!mysqli_stmt_bind_result($stmt_sel, $row['id'], $row['_bin'], $row['bit_value'], $row['_bit_value0'], $row['bit_null'])) { printf("[010 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt_sel), mysqli_stmt_error($stmt_sel)); break; } if (!mysqli_stmt_fetch($stmt_sel)) { printf("[011 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt_sel), mysqli_stmt_error($stmt_sel)); break; } if (($value != $row['id']) || (($bin != $row['_bin']) && ($bin2 != $row['_bin']))) { debug_zval_dump($row); printf("[012 - %d] Insert of %s in BIT(%d) column might have failed. id = %s, bin = %s (%s/%s)\n", $bits, $value, $bits, $row['id'], $row['_bin'], $bin, $bin2); break; } if ($value != $row['bit_value']) { debug_zval_dump($row); printf("[013 - %d] Expecting %s got %s\n", $bits, $value, $row['bit_value']); break; } if (null !== $row['bit_null']) { debug_zval_dump($row); printf("[014 - %d] Expecting null got %s/%s\n", $bits, gettype($row['bit_value']), $row['bit_value']); break; } } mysqli_stmt_close($stmt_ins); mysqli_stmt_close($stmt_sel); } mysqli_close($link_ins); mysqli_close($link_sel); print "done!"; ?> --EXPECTF-- done! --UEXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_bind_result_references.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_bind_result_references.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_bind_result_references.phpt --TEST-- mysqli_stmt_bind_result() - playing with references --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; require('table.inc'); $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 1")) printf("[001] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 1")) printf("[001] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); print "plain vanilla...\n"; unset($id); unset($label); $id = $label = null; if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label))) printf("[002] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt)) printf("[003] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); var_dump($id); var_dump($label); print "reference, one level...\n"; unset($id); unset($id_ref); unset($label); unset($label_ref); $id = null; $id_ref = &$id; $label = null; $label_ref = &$label; if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id_ref, $label_ref))) printf("[004] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt)) printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); var_dump($id_ref); var_dump($id); var_dump($label_ref); var_dump($label); print "reference, two levels...\n"; unset($id); unset($id_ref); unset($id_ref_ref); unset($label); unset($label_ref); unset($label_ref_ref); $id = null; $id_ref = &$id; $id_ref_ref = &$id_ref; $label = null; $label_ref = &$label; $label_ref_ref = &$label_ref; if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id_ref_ref, $label_ref_ref))) printf("[006] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt)) printf("[007] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); var_dump($id_ref_ref); var_dump($id_ref); var_dump($id); var_dump($label_ref_ref); var_dump($label_ref); var_dump($label); print "reference, \$GLOBALS...\n"; unset($id); unset($id_ref); unset($label); unset($label_ref); $id = 100; $id_ref = &$GLOBALS['id']; $label = null; $label_ref = &$GLOBALS['label']; if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id_ref, $label_ref))) printf("[008] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt)) printf("[009] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); var_dump($id_ref); var_dump($id); var_dump($label_ref); var_dump($label); print "reference, same target...\n"; $id = null; $label = &$id; if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label))) printf("[010] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt)) printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); var_dump($id); var_dump($label); print "reference, simple object...\n"; unset($obj); $obj = new stdClass(); $obj->id = null; $obj->label = null; if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $obj->id, $obj->label))) printf("[012] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt)) printf("[013] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); var_dump($obj->id); var_dump($obj->label); print "reference, simple object w reference...\n"; unset($id); unset($label); unset($obj); $obj = new stdClass(); $obj->id = null; $obj->label = null; $id = &$obj->id; $label = &$obj->label; if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label))) printf("[012] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt)) printf("[013] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); var_dump($obj->id); var_dump($obj->label); print "reference, simple object w reference, change after bind...\n"; unset($id); unset($label); unset($obj); $obj = new stdClass(); $obj->id = null; $obj->label = null; $id = &$obj->id; $label = &$obj->label; if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label))) printf("[012] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); $label = &$obj->id; $id = null; if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt)) printf("[013] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); var_dump($obj->id); var_dump($id); var_dump($obj->label); var_dump($label); print "reference, one level, change after bind...\n"; unset($id); unset($label); unset($id_ref); unset($label_ref); $id = null; $id_ref = &$id; $label = null; $label_ref = &$label; if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id_ref, $label_ref))) printf("[014] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); $id_ref = 1; $label_ref = 1; if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt)) printf("[015] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); var_dump($id_ref); var_dump($id); var_dump($label_ref); var_dump($label); print "reference, circle...\n"; unset($id); unset($label_a); unset($label_b); $id = null; $label_a = &$label_b; $label_b = &$label_a; if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label_a))) printf("[016] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt)) printf("[017] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); var_dump($id); var_dump($label_a); var_dump($label_b); print "reference, object, forward declaration...\n"; unset($bar); unset($id); unset($label_ref); class foo { public $foo; public function foo() { $this->foo = &$this->bar; } } class bar extends foo { public $bar = null; } $bar = new bar(); $id = null; $label_ref = &$bar->bar; if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label_ref))) printf("[018] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt)) printf("[019] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); var_dump($id); var_dump($bar); var_dump($label_ref); print "references, object, private...\n"; unset($bar); unset($id); unset($label); class mega_bar extends bar { private $id; public $id_ref; public function mega_bar() { $this->foo(); $this->id_ref = &$this->id; } } $bar = new mega_bar(); $id = &$bar->id_ref; $label = &$bar->foo; if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label))) printf("[020] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt)) printf("[021] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); var_dump($id); var_dump($label); var_dump($bar); mysqli_stmt_close($stmt); mysqli_close($link); print "done!"; ?> --EXPECTF-- plain vanilla... int(1) string(1) "a" reference, one level... int(1) int(1) string(1) "a" string(1) "a" reference, two levels... int(1) int(1) int(1) string(1) "a" string(1) "a" string(1) "a" reference, $GLOBALS... int(1) int(1) string(1) "a" string(1) "a" reference, same target... string(1) "a" string(1) "a" reference, simple object... int(1) string(1) "a" reference, simple object w reference... int(1) string(1) "a" reference, simple object w reference, change after bind... int(1) int(1) string(1) "a" int(1) reference, one level, change after bind... int(1) int(1) string(1) "a" string(1) "a" reference, circle... int(1) string(1) "a" string(1) "a" reference, object, forward declaration... int(1) object(bar)#%d (2) { ["bar"]=> &string(1) "a" ["foo"]=> &string(1) "a" } string(1) "a" references, object, private... int(1) string(1) "a" object(mega_bar)#5 (4) { [%s]=> &int(1) ["id_ref"]=> &int(1) ["bar"]=> &string(1) "a" ["foo"]=> &string(1) "a" } done! --UEXPECTF-- plain vanilla... int(1) unicode(1) "a" reference, one level... int(1) int(1) unicode(1) "a" unicode(1) "a" reference, two levels... int(1) int(1) int(1) unicode(1) "a" unicode(1) "a" unicode(1) "a" reference, $GLOBALS... int(1) int(1) unicode(1) "a" unicode(1) "a" reference, same target... unicode(1) "a" unicode(1) "a" reference, simple object... int(1) unicode(1) "a" reference, simple object w reference... int(1) unicode(1) "a" reference, simple object w reference, change after bind... int(1) int(1) unicode(1) "a" int(1) reference, one level, change after bind... int(1) int(1) unicode(1) "a" unicode(1) "a" reference, circle... int(1) unicode(1) "a" unicode(1) "a" reference, object, forward declaration... int(1) object(bar)#%d (2) { [u"bar"]=> &unicode(1) "a" [u"foo"]=> &unicode(1) "a" } unicode(1) "a" references, object, private... int(1) unicode(1) "a" object(mega_bar)#5 (4) { [u"id":u"mega_bar":private]=> &int(1) [u"id_ref"]=> &int(1) [u"bar"]=> &unicode(1) "a" [u"foo"]=> &unicode(1) "a" } done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_close.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_close.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_close.phpt --TEST-- mysqli_stmt_close() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_close())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_close($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$stmt = mysqli_stmt_init($link)) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); // Yes, amazing, eh? AFAIK a work around of a constructor bug... if (!is_null($tmp = mysqli_stmt_close($stmt))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test")) printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (true !== ($tmp = mysqli_stmt_close($stmt))) printf("[006] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = mysqli_stmt_close($stmt))) printf("[007] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$stmt = mysqli_stmt_init($link)) printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) printf("[009] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); $id = $label = null; if (!mysqli_stmt_bind_param($stmt, "is", $id, $label)) printf("[010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); $id = 100; $label = 'z'; if (!mysqli_stmt_execute($stmt)) printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); mysqli_kill($link, mysqli_thread_id($link)); if (true !== ($tmp = mysqli_stmt_close($stmt))) printf("[012] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); require('table.inc'); if (!$stmt = mysqli_stmt_init($link)) printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test")) printf("[014] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); $id = $label = null; if (!mysqli_stmt_bind_result($stmt, $id, $label)) printf("[015] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt)) printf("[016] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); mysqli_kill($link, mysqli_thread_id($link)); if (true !== ($tmp = mysqli_stmt_close($stmt))) printf("[017] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_stmt_close(): invalid object or resource mysqli_stmt in %s on line %d Warning: mysqli_stmt_close(): Couldn't fetch mysqli_stmt in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_data_seek.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_data_seek.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_data_seek.phpt --TEST-- mysqli_stmt_data_seek() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_data_seek())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_data_seek($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$stmt = mysqli_stmt_init($link)) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_null($tmp = mysqli_stmt_data_seek($stmt, 1))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, "SELECT id FROM test ORDER BY id")) printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (true !== ($tmp = mysqli_stmt_execute($stmt))) printf("[006] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); $id = null; if (!mysqli_stmt_bind_result($stmt, $id)) printf("[007] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!mysqli_stmt_store_result($stmt)) printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!is_null($tmp = mysqli_stmt_data_seek($stmt, 2))) printf("[009] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_fetch($stmt)) printf("[010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); var_dump($id); if (!is_null($tmp = mysqli_stmt_data_seek($stmt, 0))) printf("[011] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_fetch($stmt)) printf("[012] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); var_dump($id); if (!is_null($tmp = mysqli_stmt_data_seek($stmt, mysqli_stmt_num_rows($stmt) + 100))) printf("[013] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (mysqli_stmt_fetch($stmt)) printf("[014] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); var_dump($id); if (false !== ($tmp = mysqli_stmt_data_seek($stmt, -1))) printf("[015] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (mysqli_stmt_fetch($stmt)) printf("[016] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); var_dump($id); mysqli_stmt_close($stmt); if (NULL !== ($tmp = mysqli_stmt_data_seek($stmt, 0))) printf("[017] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); print "done!"; ?> --EXPECTF-- Warning: mysqli_stmt_data_seek(): invalid object or resource mysqli_stmt in %s on line %d int(3) int(1) int(1) Warning: mysqli_stmt_data_seek(): Offset must be positive in %s on line %d int(1) Warning: mysqli_stmt_data_seek(): Couldn't fetch mysqli_stmt in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_errno.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_errno.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_errno.phpt --TEST-- mysqli_stmt_errno() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_errno())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_errno($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$stmt = mysqli_stmt_init($link)) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); // properly initialized? if (0 !== ($tmp = mysqli_stmt_errno($stmt))) printf("[004] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); if (mysqli_stmt_prepare($stmt, "SELECT i_do_not_exist_believe_me FROM test ORDER BY id")) printf("[005] Statement should have failed!\n"); // set after error server? if (0 === ($tmp = mysqli_stmt_errno($stmt))) printf("[006] Expecting int/any non zero, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, "SELECT id FROM test ORDER BY id")) printf("[007] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); // reset after error & success if (0 != ($tmp = mysqli_stmt_errno($stmt))) printf("[008] Expecting zero, got %s/%s\n", gettype($tmp), $tmp); mysqli_kill($link, mysqli_thread_id($link)); if (true === ($tmp = mysqli_stmt_execute($stmt))) printf("[009] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); // set after client error if (0 === ($tmp = mysqli_stmt_errno($stmt))) printf("[010] Execting int/any non zero, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); if (NULL !== ($tmp = mysqli_stmt_errno($stmt))) printf("[011] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); print "done!"; ?> --EXPECTF-- Warning: mysqli_stmt_errno(): Couldn't fetch mysqli_stmt in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_error.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_error.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_error.phpt --TEST-- mysqli_stmt_error() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_error())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_error($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$stmt = mysqli_stmt_init($link)) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); // properly initialized? if ('' !== ($tmp = mysqli_stmt_error($stmt))) printf("[004] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); if (mysqli_stmt_prepare($stmt, "SELECT i_do_not_exist_believe_me FROM test ORDER BY id")) printf("[005] Statement should have failed!\n"); // set after error server? if ('' === ($tmp = mysqli_stmt_error($stmt))) printf("[006] Expecting string/any non empty, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, "SELECT id FROM test ORDER BY id")) printf("[007] [%d] %s\n", mysqli_stmt_error($stmt), mysqli_stmt_error($stmt)); // reset after error & success if ('' !== ($tmp = mysqli_stmt_error($stmt))) printf("[008] Expecting empty string, got %s/%s\n", gettype($tmp), $tmp); mysqli_kill($link, mysqli_thread_id($link)); if (true === ($tmp = mysqli_stmt_execute($stmt))) printf("[009] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); // set after client error if ('' === ($tmp = mysqli_stmt_error($stmt))) printf("[010] Execting string/any non empty, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); if (NULL !== ($tmp = mysqli_stmt_error($stmt))) printf("[011] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); print "done!"; ?> --EXPECTF-- Warning: mysqli_stmt_error(): Couldn't fetch mysqli_stmt in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_execute.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_execute.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_execute.phpt --TEST-- mysqli_stmt_execute() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_execute())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_execute($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$stmt = mysqli_stmt_init($link)) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); // stmt object status test if (NULL !== ($tmp = mysqli_stmt_execute($stmt))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (mysqli_stmt_prepare($stmt, "SELECT i_do_not_exist_believe_me FROM test ORDER BY id")) printf("[005] Statement should have failed!\n"); // stmt object status test if (NULL !== ($tmp = mysqli_stmt_execute($stmt))) printf("[006] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, "SELECT id FROM test ORDER BY id LIMIT 1")) printf("[007] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (true !== ($tmp = mysqli_stmt_execute($stmt))) printf("[008] Expecting boolean/true, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) printf("[009] [%d] %s\n", mysqli_stmt_execute($stmt), mysqli_stmt_execute($stmt)); // no input variables bound if (false !== ($tmp = mysqli_stmt_execute($stmt))) printf("[010] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); $id = 100; $label = "z"; if (!mysqli_stmt_bind_param($stmt, "is", $id, $label)) printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (true !== ($tmp = mysqli_stmt_execute($stmt))) printf("[012] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); mysqli_kill($link, mysqli_thread_id($link)); if (false !== ($tmp = mysqli_stmt_execute($stmt))) printf("[014] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); if (NULL !== ($tmp = mysqli_stmt_execute($stmt))) printf("[015] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); print "done!"; ?> --EXPECTF-- Warning: mysqli_stmt_execute(): invalid object or resource mysqli_stmt in %s on line %d Warning: mysqli_stmt_execute(): invalid object or resource mysqli_stmt in %s on line %d Warning: mysqli_stmt_execute(): Couldn't fetch mysqli_stmt in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_fetch.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_fetch.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_fetch.phpt --TEST-- mysqli_stmt_fetch() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php /* NOTE: no datatype tests here! This is done by mysqli_stmt_bind_result.phpt already. Restrict this test case to the basics. */ include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_fetch())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_fetch($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$stmt = mysqli_stmt_init($link)) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); // stmt object status test if (NULL !== ($tmp = mysqli_stmt_fetch($stmt))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 2")) printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); // FIXME - different versions return different values ?! if ((NULL !== ($tmp = mysqli_stmt_fetch($stmt))) && (false !== $tmp)) printf("[006] Expecting NULL or boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_execute($stmt)) printf("[007] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (true !== ($tmp = mysqli_stmt_fetch($stmt))) printf("[008] NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); if (!$stmt = mysqli_stmt_init($link)) printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 2")) printf("[010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!mysqli_stmt_execute($stmt)) printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); $id = NULL; $label = NULL; if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label))) printf("[012] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = mysqli_stmt_fetch($stmt))) printf("[013] Expecting boolean/true, got %s/%s, [%d] %s\n", gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!mysqli_kill($link, mysqli_thread_id($link))) printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (true !== ($tmp = mysqli_stmt_fetch($stmt))) printf("[015] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); if (NULL !== ($tmp = mysqli_stmt_fetch($stmt))) printf("[016] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); /* Check that the function alias exists. It's a deprecated function, but we have not announce the removal so far, therefore we need to check for it */ if (!is_null($tmp = @mysqli_fetch())) printf("[017] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_stmt_fetch(): invalid object or resource mysqli_stmt in %s on line %d [014] [%d] Commands out of sync; you can't run this command now Warning: mysqli_stmt_fetch(): Couldn't fetch mysqli_stmt in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_fetch_bit.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_fetch_bit.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_fetch_bit.phpt --TEST-- Fetching BIT column values using the PS API --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('connect.inc'); require_once('table.inc'); if (mysqli_get_server_version($link) < 50003) // b'001' syntax not supported before 5.0.3 die("skip Syntax used for test not supported with MySQL Server before 5.0.3"); if (!$IS_MYSQLND && (mysqli_get_client_version() < 50003)) // better don't trust libmysql before 5.0.3 die("skip Syntax used for test not supported with MySQL Server before 5.0.3"); ?> --FILE-- <?php require('connect.inc'); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); for ($bits = 1; $bits < 64; $bits++) { $max_value = pow(2, $bits) - 1; $tests = 0; if (!mysqli_query($link, "DROP TABLE IF EXISTS test") || !mysqli_query($link, $sql = sprintf('CREATE TABLE test(id INT, label BIT(%d)) ENGINE="%s"', $bits, $engine))) printf("[002 - %d] [%d] %s\n",$bits, mysqli_errno($link), mysqli_error($link)); if (!$stmt = mysqli_stmt_init($link)) printf("[003 - %d] [%d] %s\n", $bits, mysqli_errno($link), mysqli_error($link)); while ($tests < min($max_value, 20)) { $tests++; $value = mt_rand(0, $max_value); $sql = sprintf("INSERT INTO test(id, label) VALUES (%d, b'%s')", $value, decbin($value)); if (!mysqli_stmt_prepare($stmt, $sql) || !mysqli_stmt_execute($stmt)) printf("[004 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); $id = $_label0 = $label = null; $sql = sprintf("SELECT id, label + 0 AS _label0, label FROM test WHERE id = %d", $value); if (!mysqli_stmt_prepare($stmt, $sql) || !mysqli_stmt_execute($stmt) || !mysqli_stmt_bind_result($stmt, $id, $_label0, $label)) printf("[005 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!mysqli_stmt_fetch($stmt)) printf("[006 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (($id !== $_label0) || ($value !== $_label0)) { printf("[007 - %d] Insert of %d in BIT(%d) column might have failed. MySQL reports odd values, id = %s, _label0 = %s, label = %s.\n", $bits, $value, $bits, $id, $_label0, $label); } if ($value != $label) { printf("[008 - %d] Wrong values, (original) value = %s, id = %s, label + 0 AS label0 = %s, label = %s\n", $bits, $value, $id, $_label0, $label); } } mysqli_stmt_close($stmt); } mysqli_close($link); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_fetch_fields_win32_unicode.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_fetch_fields_win32_unicode.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_fetch_fields_win32_unicode.phpt --TEST-- mysqli_stmt_fetch_fields() unicode, win32 --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; require('table.inc'); $bind_res = $id = null; if (!($stmt = mysqli_stmt_init($link)) || !mysqli_stmt_prepare($stmt, "SELECT id, label FROM test") || !mysqli_stmt_execute($stmt) || !($result = mysqli_stmt_result_metadata($stmt)) || !mysqli_stmt_bind_result($stmt, $id, $bind_res) || !($fields = mysqli_fetch_fields($result))) { printf("FAIL 1\n"); } while (mysqli_stmt_fetch($stmt)) { ; } mysqli_free_result($result); mysqli_stmt_close($stmt); if (!($stmt = mysqli_stmt_init($link)) || !mysqli_stmt_prepare($stmt, "SELECT id, label FROM test") || !mysqli_stmt_execute($stmt) || !($result = mysqli_stmt_result_metadata($stmt)) || !mysqli_stmt_bind_result($stmt, $id, $bind_res)) { printf("FAIL 2\n"); } print "OK: 1\n"; if (!($fields = mysqli_fetch_fields($result))) printf("Aua 3\n"); print "OK: 2\n"; while (mysqli_stmt_fetch($stmt)) { ; } mysqli_free_result($result); mysqli_stmt_close($stmt); mysqli_close($link); print "done!"; ?> --EXPECTF-- OK: 1 OK: 2 done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_field_count.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_field_count.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_field_count.phpt --TEST-- mysqli_stmt_field_counts() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_field_count())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_field_count($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); $stmt = mysqli_stmt_init($link); if (!is_null($tmp = mysqli_stmt_field_count($stmt))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (mysqli_stmt_prepare($stmt, '')) printf("[004] Prepare should fail for an empty statement\n"); if (!is_null($tmp = mysqli_stmt_field_count($stmt))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, 'SELECT 1')) printf("[006] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (1 !== ($tmp = mysqli_stmt_field_count($stmt))) printf("[007] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, 'SELECT 1, 2')) printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (2 !== ($tmp = mysqli_stmt_field_count($stmt))) printf("[009] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test')) printf("[010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (2 !== ($tmp = mysqli_stmt_field_count($stmt))) printf("[011] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, 'SELECT label FROM test') || !mysqli_stmt_execute($stmt)) printf("[012] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (1 !== ($tmp = mysqli_stmt_field_count($stmt))) printf("[013] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); $label = null; if (mysqli_stmt_bind_param($stmt, "s", $label)) printf("[014] expected error - got ok\n"); while (mysqli_stmt_fetch($stmt)) if (1 !== ($tmp = mysqli_stmt_field_count($stmt))) printf("[015] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, 'INSERT INTO test(id) VALUES (100)')) printf("[016] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (0 !== ($tmp = mysqli_stmt_field_count($stmt))) printf("[017] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, 'UPDATE test SET label = "z" WHERE id = 1') || !mysqli_stmt_execute($stmt)) printf("[018] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (0 !== ($tmp = mysqli_stmt_field_count($stmt))) printf("[019] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); if (mysqli_stmt_prepare($stmt, 'SELECT id FROM test')) printf("[020] Prepare should fail, statement has been closed\n"); if (!is_null($tmp = mysqli_stmt_field_count($stmt))) printf("[011] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); print "done!"; ?> --EXPECTF-- Warning: mysqli_stmt_field_count(): invalid object or resource mysqli_stmt in %s on line %d Warning: mysqli_stmt_field_count(): invalid object or resource mysqli_stmt in %s on line %d Warning: mysqli_stmt_prepare(): Couldn't fetch mysqli_stmt in %s on line %d Warning: mysqli_stmt_field_count(): Couldn't fetch mysqli_stmt in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_free_result.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_free_result.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_free_result.phpt --TEST-- mysqli_stmt_free_result() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php /* NOTE: no datatype tests here! This is done by mysqli_stmt_bind_result.phpt already. Restrict this test case to the basics. */ include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_free_result())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_free_result($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$stmt = mysqli_stmt_init($link)) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); // stmt object status test if (NULL !== ($tmp = mysqli_stmt_free_result($stmt))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id")) printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (NULL !== ($tmp = mysqli_stmt_free_result($stmt))) printf("[006] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_execute($stmt)) printf("[007] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (NULL !== ($tmp = mysqli_stmt_free_result($stmt))) printf("[008] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysqli_stmt_store_result($stmt))) printf("[009] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); if (!$stmt = mysqli_stmt_init($link)) printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id")) printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!mysqli_stmt_execute($stmt)) printf("[012] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (true !== ($tmp = mysqli_stmt_store_result($stmt))) printf("[013] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = mysqli_stmt_free_result($stmt))) printf("[014] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); if (NULL !== ($tmp = mysqli_stmt_free_result($stmt))) printf("[015] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); print "done!"; ?> --EXPECTF-- Warning: mysqli_stmt_free_result(): invalid object or resource mysqli_stmt in %s on line %d Warning: mysqli_stmt_free_result(): Couldn't fetch mysqli_stmt in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_get_warnings.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_get_warnings.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_get_warnings.phpt --TEST-- mysqli_stmt_get_warnings() - TODO --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('connect.inc'); if (!$TEST_EXPERIMENTAL) die("skip - experimental (= unsupported) feature"); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_get_warnings())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_get_warnings($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$stmt = mysqli_stmt_init($link)) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (NULL !== ($tmp = mysqli_stmt_get_warnings($stmt))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, "DROP TABLE IF EXISTS test") || !mysqli_stmt_execute($stmt)) printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (false !== ($tmp = mysqli_stmt_get_warnings($stmt))) printf("[006] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, "CREATE TABLE test(id SMALLINT, label CHAR(1))") || !mysqli_stmt_execute($stmt)) printf("[007] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (false !== ($tmp = mysqli_stmt_get_warnings($stmt))) printf("[008] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (100000, 'a'), (100001, 'b')") || !mysqli_stmt_execute($stmt)) printf("[009] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!is_object($warning = mysqli_stmt_get_warnings($stmt))) printf("[010] Expecting mysqli_warning object, got %s/%s\n", gettype($warning), $warning); if ('mysqli_warning' !== get_class($warning)) printf("[011] Expecting object of type mysqli_warning got type '%s'", get_class($warning)); if (!method_exists($warning, 'next')) printf("[012] Object mysqli_warning seems to lack method next()\n"); $i = 0; do { if ('' == $warning->message) printf("[013 - %d] Message should not be empty\n", $i); if ('' == $warning->sqlstate) printf("[014 - %d] SQL State should not be empty\n", $i); if (0 == $warning->errno) printf("[015 - %d] Error number should not be zero\n", $i); $i++; } while ($warning->next()); if (2 != $i) printf("[016] Expected 2 warnings, got %d warnings\n", $i); mysqli_stmt_close($stmt); if (NULL !== ($tmp = mysqli_stmt_get_warnings($stmt))) printf("[015] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); print "done!"; ?> --EXPECTF-- Warning: mysqli_stmt_get_warnings(): invalid object or resource mysqli_stmt in %s on line %d Warning: mysqli_stmt_get_warnings(): Couldn't fetch mysqli_stmt in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_init.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_init.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_init.phpt --TEST-- mysqli_stmt_init() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php /* NOTE: no datatype tests here! This is done by mysqli_stmt_bind_result.phpt already. Restrict this test case to the basics. */ include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_init())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_init($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!is_object($stmt = mysqli_stmt_init($link))) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_object($stmt2 = @mysqli_stmt_init($link))) printf("[003a] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_stmt_close($stmt); if (NULL !== ($tmp = mysqli_stmt_init($stmt))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); if (NULL !== ($tmp = mysqli_stmt_init($link))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_stmt_close(): invalid object or resource mysqli_stmt in %s on line %d Warning: mysqli_stmt_init() expects parameter 1 to be mysqli, object given in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_insert_id.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_insert_id.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_insert_id.phpt --TEST-- mysqli_stmt_insert_id() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_insert_id())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); $stmt = @new mysqli_stmt($link); if (!is_null($tmp = @mysqli_insert_id($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); $stmt = mysqli_stmt_init($link); if (NULL !== ($tmp = @mysqli_stmt_insert_id($stmt))) printf("[003] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 1") || !mysqli_stmt_execute($stmt)) { printf("[004] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); } if (0 !== ($tmp = mysqli_stmt_insert_id($stmt))) printf("[005] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); // no auto_increment column $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (100, 'a')") || !mysqli_stmt_execute($stmt)) { printf("[006] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); } if (0 !== ($tmp = mysqli_stmt_insert_id($stmt))) printf("[007] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); if (mysqli_get_server_version($link) > 50000 && (!mysqli_stmt_prepare($stmt, "ALTER TABLE test MODIFY id INT NOT NULL AUTO_INCREMENT") || !mysqli_stmt_execute($stmt))) { printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); } else if (mysqli_get_server_version($link) < 50000){ mysqli_query($link, "ALTER TABLE test MODIFY id INT NOT NULL AUTO_INCREMENT"); } if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(label) VALUES ('a')") || !mysqli_stmt_execute($stmt)) { printf("[009] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); } if (0 === ($tmp = mysqli_stmt_insert_id($stmt))) printf("[010] Expecting int/any non zero, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); mysqli_close($link); var_dump(mysqli_stmt_insert_id($stmt)); print "done!"; ?> --EXPECTF-- Warning: mysqli_stmt_insert_id(): Couldn't fetch mysqli_stmt in %s on line %d NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_num_rows.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_num_rows.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_num_rows.phpt --TEST-- mysqli_stmt_num_rows() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_num_rows())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_num_rows($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$stmt = mysqli_stmt_init($link)) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); function func_test_mysqli_stmt_num_rows($stmt, $query, $expected, $offset) { if (!mysqli_stmt_prepare($stmt, $query)) { printf("[%03d] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_error($stmt)); return false; } if (!mysqli_stmt_execute($stmt)) { printf("[%03d] [%d] %s\n", $offset + 1, mysqli_errno($stmt), mysqli_error($stmt)); return false; } if (!mysqli_stmt_store_result($stmt)) { printf("[%03d] [%d] %s\n", $offset + 2, mysqli_errno($stmt), mysqli_error($stmt)); return false; } if ($expected !== ($tmp = mysqli_stmt_num_rows($stmt))) printf("[%03d] Expecting %s/%d, got %s/%d\n", $offset + 3, gettype($expected), $expected, gettype($tmp), $tmp); mysqli_stmt_free_result($stmt); return true; } func_test_mysqli_stmt_num_rows($stmt, "SELECT 1 AS a", 1, 10); func_test_mysqli_stmt_num_rows($stmt, "SHOW VARIABLES LIKE '%nixnutz%'", 0, 20); // Note: for statements that return no result set mysqli_num_rows() differs from mysqli_stmt_num_rows() slightly // mysqli_num_rows() failed to fetch the result set and the PHP parameter check makes it return NULL // mysqli_stmt_numrows() has a valid resource to work on and it will return int/0 instead. No bug, but // slightly different behaviour... - if you really check the data types and don't rely on casting like 98% of all PHP // users do. func_test_mysqli_stmt_num_rows($stmt, "INSERT INTO test(id, label) VALUES (100, 'z')", 0, 30); if ($res = mysqli_query($link, 'SELECT COUNT(id) AS num FROM test')) { $row = mysqli_fetch_assoc($res); mysqli_free_result($res); func_test_mysqli_stmt_num_rows($stmt, "SELECT id, label FROM test", (int)$row['num'], 40); } else { printf("[050] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } print "run_tests.php don't fool me with your 'ungreedy' expression '.+?'!\n"; if (!mysqli_stmt_prepare($stmt, 'SELECT id FROM test')) printf("[051] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (mysqli_stmt_execute($stmt)) { $i = 0; do { if (0 !== ($tmp = mysqli_stmt_num_rows($stmt))) printf("[53 - %03d] Expecting int/0, got %s/%s\n", $i, gettype($tmp), $tmp); $i++; } while (mysqli_stmt_fetch($stmt)); if (0 !== ($tmp = mysqli_stmt_num_rows($stmt))) printf("[54] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); } else { printf("[055] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); } mysqli_stmt_close($stmt); if (NULL !== ($tmp = mysqli_stmt_num_rows($stmt))) printf("[056] Expecting NULL, got %s/%s\n"); mysqli_close($link); print "done!"; ?> --EXPECTF-- run_tests.php don't fool me with your 'ungreedy' expression '.+?'! Warning: mysqli_stmt_num_rows(): Couldn't fetch mysqli_stmt in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_param_count.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_param_count.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_param_count.phpt --TEST-- mysqli_stmt_param_count() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_param_count())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_param_count($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$stmt = mysqli_stmt_init($link)) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (NULL !== ($tmp = mysqli_stmt_param_count($stmt))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); function func_test_mysqli_stmt_param_count($stmt, $query, $expected, $offset) { if (!mysqli_stmt_prepare($stmt, $query)) { printf("[%03d] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_error($stmt)); return false; } if ($expected !== ($tmp = mysqli_stmt_param_count($stmt))) printf("[%03d] Expecting %s/%d, got %s/%d\n", $offset + 3, gettype($expected), $expected, gettype($tmp), $tmp); return true; } func_test_mysqli_stmt_param_count($stmt, "SELECT 1 AS a", 0, 10); func_test_mysqli_stmt_param_count($stmt, "INSERT INTO test(id) VALUES (?)", 1, 20); func_test_mysqli_stmt_param_count($stmt, "INSERT INTO test(id, label) VALUES (?, ?)", 2, 30); func_test_mysqli_stmt_param_count($stmt, "INSERT INTO test(id, label) VALUES (?, '?')", 1, 40); mysqli_stmt_close($stmt); if (NULL !== ($tmp = mysqli_stmt_param_count($stmt))) printf("[40] Expecting NULL, got %s/%s\n"); mysqli_close($link); /* Check that the function alias exists. It's a deprecated function, but we have not announce the removal so far, therefore we need to check for it */ if (!is_null($tmp = @mysqli_param_count())) printf("[041] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_stmt_param_count(): invalid object or resource mysqli_stmt in %s on line %d Warning: mysqli_stmt_param_count(): Couldn't fetch mysqli_stmt in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_prepare.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_prepare.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_prepare.phpt --TEST-- mysqli_stmt_prepare() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; // Note: No SQL tests here! We can expand one of the *fetch() // tests to a generic SQL test, if we ever need that. // We would duplicate the SQL test cases if we have it here and in one of the // fetch tests, because the fetch tests would have to call prepare/execute etc. // anyway. $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_prepare())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_prepare($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$stmt = mysqli_stmt_init($link)) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (NULL !== ($tmp = @mysqli_stmt_prepare($stmt))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysqli_stmt_prepare($stmt, ''))) printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = mysqli_stmt_prepare($stmt, 'SELECT id FROM test'))) printf("[006] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); if (NULL !== ($tmp = mysqli_stmt_prepare($stmt, "SELECT id FROM test"))) printf("[007] Expecting NULL, got %s/%s\n"); mysqli_close($link); print "done!"; ?> --EXPECTF-- Warning: mysqli_stmt_prepare(): Couldn't fetch mysqli_stmt in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_reset.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_reset.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_reset.phpt --TEST-- mysqli_stmt_reset() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; // Note: No SQL tests here! We can expand one of the *fetch() // tests to a generic SQL test, if we ever need that. // We would duplicate the SQL test cases if we have it here and in one of the // fetch tests, because the fetch tests would have to call prepare/execute etc. // anyway. $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_reset())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_reset($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$stmt = mysqli_stmt_init($link)) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (NULL !== ($tmp = mysqli_stmt_reset($stmt))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = mysqli_stmt_prepare($stmt, 'SELECT id FROM test'))) printf("[005] Expecting boolean/true, got %s/%s, [%d] %s\n", gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (true !== ($tmp = mysqli_stmt_reset($stmt))) printf("[006] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = mysqli_stmt_execute($stmt))) printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); $id = null; if (!mysqli_stmt_bind_result($stmt, $id)) printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!mysqli_stmt_fetch($stmt)) printf("[009] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); var_dump($id); mysqli_stmt_close($stmt); if (!$stmt = mysqli_stmt_init($link)) printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, "CREATE TABLE test(id INT NOT NULL AUTO_INCREMENT, label BLOB, PRIMARY KEY(id))")) printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(label) VALUES (?)")) printf("[013] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); $label = null; if (!mysqli_stmt_bind_param($stmt, "b", $label)) printf("[014] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); $label = 'abc'; for ($i = 0; $i < 10; $i++) { if (!mysqli_stmt_send_long_data($stmt, 0, $label)) printf("[015 - %d] [%d] %s\n", $i, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); } if (!mysqli_stmt_reset($stmt)) printf("[016] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!mysqli_stmt_execute($stmt)) printf("[017] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!$res = mysqli_query($link, "SELECT label FROM test")) printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$row = mysqli_fetch_assoc($res)) printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_free_result($res); if ($row['label'] != '') printf("[020] Expecting empty string, got string/%s\n", $row['label']); mysqli_stmt_close($stmt); if (NULL !== ($tmp = mysqli_stmt_reset($stmt))) printf("[021] Expecting NULL, got %s/%s\n"); mysqli_close($link); print "done!"; ?> --EXPECTF-- Warning: mysqli_stmt_reset(): invalid object or resource mysqli_stmt in %s on line %d int(1) Warning: mysqli_stmt_reset(): Couldn't fetch mysqli_stmt in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_result_metadata.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_result_metadata.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_result_metadata.phpt --TEST-- mysqli_stmt_result_metadata() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_result_metadata())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_result_metadata($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$stmt = mysqli_stmt_init($link)) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (NULL !== ($tmp = mysqli_stmt_result_metadata($stmt))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test")) printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!is_object(($res = mysqli_stmt_result_metadata($stmt)))) printf("[006] Expecting object, got %s/%s\n", gettype($tmp), $tmp); if (2 !== ($tmp = mysqli_num_fields($res))) printf("[007] Expecting int/2, got %s/%s, [%d] %s\n", gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link)); if (!is_object($field0_fetch = mysqli_fetch_field($res))) printf("[008] Expecting object, got %s/%s, [%d] %s\n", gettype($field0_fetch), $field0_fetch, mysqli_errno($link), mysqli_error($link)); if (!is_object($field0_direct = mysqli_fetch_field_direct($res, 0))) printf("[009] Expecting object, got %s/%s, [%d] %s\n", gettype($field0_direct), $field0_direct, mysqli_errno($link), mysqli_error($link)); if ($field0_fetch != $field0_direct) { printf("[010] mysqli_fetch_field() differs from mysqli_fetch_field_direct()\n"); var_dump($field0_fetch); var_dump($field0_direct); } var_dump($field0_fetch); if (!is_array($tmp = mysqli_fetch_fields($res))) printf("[011] Expecting array, got %s/%s, [%d] %s\n", gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link)); if (empty($tmp[0]) || empty($tmp[1]) || $tmp[0] != $field0_direct) { printf("[012] mysqli_fetch_fields() return value is suspicious\n"); var_dump($tmp); } if (!mysqli_field_seek($res, 1)) printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_object($field1_direct = mysqli_fetch_field_direct($res, 1))) printf("[014] Expecting object, got %s/%s, [%d] %s\n", gettype($field1_direct), $field1_direct, mysqli_errno($link), mysqli_error($link)); if ($tmp[1] != $field1_direct) { printf("[015] mysqli_fetch_field_direct() differs from mysqli_fetch_fields()\n"); var_dump($field1_direct); var_dump($tmp); } if (1 !== ($tmp = mysqli_field_tell($res))) printf("[016] Expecting int/1, got %s/%s, [%d] %s\n", gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link)); mysqli_free_result($res); mysqli_stmt_close($stmt); if (NULL !== ($tmp = mysqli_stmt_result_metadata($stmt))) printf("[017] Expecting NULL, got %s/%s\n"); /* Check that the function alias exists. It's a deprecated function, but we have not announce the removal so far, therefore we need to check for it */ if (!is_null($tmp = @mysqli_get_metadata())) printf("[018] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); print "done!"; ?> --EXPECTF-- Warning: mysqli_stmt_result_metadata(): invalid object or resource mysqli_stmt in %s on line %d object(stdClass)#5 (%d) { ["name"]=> string(2) "id" ["orgname"]=> string(2) "id" ["table"]=> string(4) "test" ["orgtable"]=> string(4) "test" ["def"]=> string(0) "" ["max_length"]=> int(0) ["length"]=> int(11) ["charsetnr"]=> int(63) ["flags"]=> int(49155) ["type"]=> int(3) ["decimals"]=> int(0) } Warning: mysqli_stmt_result_metadata(): Couldn't fetch mysqli_stmt in %s on line %d done! --UEXPECTF-- Warning: mysqli_stmt_result_metadata(): invalid object or resource mysqli_stmt in %s on line %d object(stdClass)#5 (%d) { [u"name"]=> unicode(2) "id" [u"orgname"]=> unicode(2) "id" [u"table"]=> unicode(4) "test" [u"orgtable"]=> unicode(4) "test" [u"def"]=> unicode(0) "" [u"max_length"]=> int(0) [u"length"]=> int(11) [u"charsetnr"]=> int(63) [u"flags"]=> int(49155) [u"type"]=> int(3) [u"decimals"]=> int(0) } Warning: mysqli_stmt_result_metadata(): Couldn't fetch mysqli_stmt in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_result_metadata_sqltests.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_result_metadata_sqltests.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_result_metadata_sqltests.phpt --TEST-- mysqli_stmt_result_metadata() - non SELECT statements --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; require('table.inc'); function testStatement($offset, $link, $sql, $expected_lib, $expected_mysqlnd, $check_mysqlnd, $compare) { if (!$stmt = mysqli_stmt_init($link)) { printf("[%04d - %s] [%d] %s\n", $offset, $sql, mysqli_errno($link), mysqli_error($link)); return false; } if (!@mysqli_stmt_prepare($stmt, $sql)) { /* Not all server versions will support all statements */ /* Failing to prepare is OK */ return true; } $res = mysqli_stmt_result_metadata($stmt); if (empty($expected_lib) && (false !== $res)) { printf("[%04d - %s] No metadata expected\n", $offset + 1, $sql); return false; } else if (!empty($expected_lib) && (false == $res)) { printf("[%04d - %s] Metadata expected\n", $offset + 2, $sql); return false; } if (!empty($expected_lib)) { if (!is_object($res)) { printf("[%04d - %s] [%d] %s\n", $offset + 3, $sql, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); return false; } if (get_class($res) != 'mysqli_result') { printf("[%04d - %s] Expecting object/mysqli_result got object/%s\n", $offset + 4, $sql, get_class($res)); return false; } $meta = array( 'num_fields' => mysqli_num_fields($res), 'fetch_field' => mysqli_fetch_field($res), 'fetch_field_direct0' => mysqli_fetch_field_direct($res, 0), 'fetch_field_direct1' => @mysqli_fetch_field_direct($res, 1), 'fetch_fields' => count(mysqli_fetch_fields($res)), 'field_count' => $res->field_count, 'field_seek-1' => @mysqli_field_seek($res, -1), 'field_seek0' => mysqli_field_seek($res, 0), 'field_tell' => mysqli_field_tell($res), ); if (is_object($meta['fetch_field'])) { $meta['fetch_field']->charsetnr = 'ignore'; $meta['fetch_field']->flags = 'ignore'; } if (is_object($meta['fetch_field_direct0'])) { $meta['fetch_field_direct0']->charsetnr = 'ignore'; $meta['fetch_field_direct0']->flags = 'ignore'; } if (is_object($meta['fetch_field_direct1'])) { $meta['fetch_field_direct1']->charsetnr = 'ignore'; $meta['fetch_field_direct1']->flags = 'ignore'; } mysqli_free_result($res); if ($meta != $expected_lib) { printf("[%04d - %s] Metadata differes from expected values\n", $offset + 5, $sql); var_dump($meta); var_dump($expected_lib); return false; } } if (function_exists('mysqli_stmt_get_result')) { /* mysqlnd only */ if (!mysqli_stmt_execute($stmt)) { printf("[%04d - %s] [%d] %s\n", $offset + 6, $sql, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); return false; } $res = mysqli_stmt_get_result($stmt); if (false === $res && !empty($expected_mysqlnd)) { printf("[%04d - %s] Expecting resultset [%d] %s\n", $offset + 7, $sql, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); return false; } else if (empty($expected_mysqlnd) && false !== $res) { printf("[%04d - %s] Unexpected resultset [%d] %s\n", $offset + 8, $sql, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); return false; } if (!is_object($res)) { printf("[%04d - %s] [%d] %s\n", $offset + 9, $sql, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); return false; } if ('mysqli_result' != get_class($res)) { printf("[%04d - %s] Expecting object/mysqli_result got object/%s\n", $offset + 10, $sql, get_class($res)); return false; } $meta_res = array( 'num_fields' => mysqli_num_fields($res), 'fetch_field' => mysqli_fetch_field($res), 'fetch_field_direct0' => mysqli_fetch_field_direct($res, 0), 'fetch_field_direct1' => @mysqli_fetch_field_direct($res, 1), 'fetch_fields' => count(mysqli_fetch_fields($res)), 'field_count' => mysqli_field_count($link), 'field_seek-1' => @mysqli_field_seek($res, -1), 'field_seek0' => mysqli_field_seek($res, 0), 'field_tell' => mysqli_field_tell($res), ); if (is_object($meta_res['fetch_field'])) { $meta_res['fetch_field']->charsetnr = 'ignore'; $meta_res['fetch_field']->flags = 'ignore'; } if (is_object($meta_res['fetch_field_direct0'])) { $meta_res['fetch_field_direct0']->charsetnr = 'ignore'; $meta_res['fetch_field_direct0']->flags = 'ignore'; } if (is_object($meta_res['fetch_field_direct1'])) { $meta_res['fetch_field_direct1']->charsetnr = 'ignore'; $meta_res['fetch_field_direct1']->flags = 'ignore'; } mysqli_free_result($res); if ($check_mysqlnd && $meta_res != $expected_mysqlnd) { printf("[%04d - %s] Metadata differs from expected\n", $offset + 11, $sql); var_dump($meta_res); var_dump($expected_mysqlnd); } else { if ($meta_res['field_count'] < 1) { printf("[%04d - %s] Metadata seems wrong, no fields?\n", $offset + 12, $sql); var_dump($meta_res); var_dump(mysqli_fetch_assoc($res)); } } if ($compare && $meta_res != $meta) { printf("[%04d - %s] Metadata returned by mysqli_stmt_result_metadata() and mysqli_stmt_get_result() differ\n", $offset + 13, $sql); var_dump($meta_res); var_dump($meta); } } mysqli_stmt_close($stmt); return true; } /* Note: very weak testing, we accept almost any result */ testStatement(100, $link, 'ANALYZE TABLE test', array(), array(1), false, false); testStatement(120, $link, 'OPTIMIZE TABLE test', array(), array(1), false, false); testStatement(140, $link, 'REPAIR TABLE test', array(), array(1), false, false); testStatement(160, $link, 'SHOW AUTHORS', array(), array(1), false, false); testStatement(180, $link, 'SHOW CHARACTER SET', array(), array(1), false, false); testStatement(200, $link, 'SHOW COLLATION', array(), array(1), false, false); testStatement(220, $link, 'SHOW CONTRIBUTORS', array(), array(1), false, false); testStatement(240, $link, 'SHOW CREATE DATABASE ' . $db, array(), array(1), false, false); testStatement(260, $link, 'SHOW DATABASES', array(), array(1), false, false); testStatement(280, $link, 'SHOW ENGINE InnoDB STATUS', array(), array(1), false, false); testStatement(300, $link, 'SHOW ENGINES', array(), array(1), false, false); testStatement(320, $link, 'SHOW PLUGINS', array(), array(1), false, false); testStatement(340, $link, 'SHOW PROCESSLIST', array(), array(1), false, false); testStatement(360, $link, 'SHOW FULL PROCESSLIST', array(), array(1), false, false); testStatement(380, $link, 'SHOW STATUS', array(), array(1), false, false); testStatement(400, $link, 'SHOW TABLE STATUS', array(), array(1), false, false); testStatement(420, $link, 'SHOW TABLE STATUS', array(), array(1), false, false); testStatement(440, $link, 'SHOW TABLES', array(), array(1), false, false); testStatement(460, $link, 'SHOW OPEN TABLES', array(), array(1), false, false); testStatement(460, $link, 'SHOW VARIABLES', array(), array(1), false, false); $field0 = new stdClass(); $field0->name = 'id'; $field0->orgname = 'id'; $field0->table = 'test'; $field0->orgtable = 'test'; $field0->def = ''; $field0->max_length = 0; $field0->length = 11; $field0->charsetnr = 'ignore'; $field0->flags = 'ignore'; $field0->type = MYSQLI_TYPE_LONG; $field0->decimals = 0; $meta_lib = array( 'num_fields' => 1, 'fetch_field' => $field0, 'fetch_field_direct0' => $field0, 'fetch_field_direct1' => false, 'fetch_fields' => 1, 'field_count' => 1, 'field_seek-1' => false, 'field_seek0' => true, 'field_tell' => 0, ); $meta_mysqlnd = $meta_lib; testStatement(480, $link, 'SELECT id FROM test', $meta_lib, $meta_mysqlnd, true, true); testStatement(500, $link, 'CHECKSUM TABLE test', array(), array(1), false, false); mysqli_close($link); print "done!"; ?> --EXPECTF-- done! --UEXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_sqlstate.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_sqlstate.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_sqlstate.phpt --TEST-- mysqli_stmt_sqlstate() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_sqlstate())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_sqlstate($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!is_null($tmp = @mysqli_stmt_sqlstate($link, ''))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$stmt = mysqli_stmt_init($link)) printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (NULL !== ($tmp = mysqli_stmt_sqlstate($stmt))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, "SELECT id FROM test")) printf("[006] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if ('00000' !== ($tmp = mysqli_stmt_sqlstate($stmt))) printf("[007] Expecting string/00000, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (mysqli_stmt_prepare($stmt, "SELECT believe_me FROM i_dont_belive_that_this_table_exists")) printf("[008] Should fail! [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if ('' === ($tmp = mysqli_stmt_sqlstate($stmt))) printf("[009] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); mysqli_stmt_close($stmt); if (NULL !== ($tmp = mysqli_stmt_sqlstate($stmt))) printf("[010] Expecting NULL, got %s/%s\n"); mysqli_close($link); print "done!"; ?> --EXPECTF-- Warning: mysqli_stmt_sqlstate(): invalid object or resource mysqli_stmt in %s on line %d Warning: mysqli_stmt_sqlstate(): Couldn't fetch mysqli_stmt in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_store_result.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_store_result.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_store_result.phpt --TEST-- mysqli_stmt_store_result() --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_store_result())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_store_result($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!is_null($tmp = @mysqli_stmt_store_result(new mysqli_stmt()))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$stmt = mysqli_stmt_init($link)) printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); // stmt object status test if (NULL !== ($tmp = @mysqli_stmt_store_result($stmt))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, 'INSERT INTO test(id, label) VALUES (100, "z")') || !mysqli_stmt_execute($stmt)) printf("[006] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (true !== ($tmp = @mysqli_stmt_store_result($stmt))) printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test ORDER BY id') || !mysqli_stmt_execute($stmt)) printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!$link_buf = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[009] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); if (!$stmt_buf = mysqli_stmt_init($link_buf)) printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_stmt_prepare($stmt_buf, "SELECT id, label FROM test ORDER BY id") || !mysqli_stmt_execute($stmt_buf)) printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt_buf), mysqli_stmt_error($stmt_buf)); $id = $label = $id_buf = $label_buf = null; if (!mysqli_stmt_bind_result($stmt, $id, $label)) printf("[012] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!mysqli_stmt_bind_result($stmt_buf, $id_buf, $label_buf)) printf("[013] [%d] %s\n", mysqli_stmt_errno($stmt_buf), mysqli_stmt_error($stmt_buf)); while (mysqli_stmt_fetch($stmt)) { if (!mysqli_stmt_fetch($stmt_buf)) { printf("[014] Unbuffered statement indicates more rows than buffered, [%d] %s\n", mysqli_stmt_errno($stmt_buf), mysqli_stmt_error($stmt_buf)); } if ($id !== $id_buf) printf("[015] unbuffered '%s'/%s, buffered '%s'/%s\n", $id, gettype($id), $id_buf, gettype($id_buf)); if ($label !== $label_buf) printf("[016] unbuffered '%s'/%s, buffered '%s'/%s\n", $label, gettype($label), $label_buf, gettype($label_buf)); } mysqli_stmt_close($stmt); mysqli_stmt_close($stmt_buf); if (NULL !== ($tmp = @mysqli_stmt_store_result($stmt))) printf("[017] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); mysqli_close($link_buf); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_store_result.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_store_result.phpt +++ php-src/ext/mysqli/tests/mysqli_store_result.phpt --TEST-- mysqli_store_result() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_store_result())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_store_result($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id")) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_object($res = mysqli_store_result($link))) printf("[004] Expecting object, got %s/%s. [%d] %s\n", gettype($res), $res, mysqli_errno($link), mysqli_error($link)); if (true !== ($tmp = mysqli_data_seek($res, 2))) printf("[005] Expecting boolean/true, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link)); mysqli_free_result($res); if (!mysqli_query($link, "DELETE FROM test")) printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (false !== ($res = mysqli_store_result($link))) printf("[007] Expecting boolean/false, got %s/%s. [%d] %s\n", gettype($res), $res, mysqli_errno($link), mysqli_error($link)); if (!$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id")) printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (false !== ($tmp = mysqli_data_seek($res, 1))) printf("[009] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); if (NULL !== ($tmp = mysqli_store_result($link))) printf("[010] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_store_result(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_thread_id.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_thread_id.phpt +++ php-src/ext/mysqli/tests/mysqli_thread_id.phpt --TEST-- mysqli_thread_id() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_thread_id())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_thread_id($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!is_int($tmp = mysqli_thread_id($link)) || (0 === $tmp)) printf("[003] Expecting int/any but zero, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link)); // should work if the thread id is correct mysqli_kill($link, mysqli_thread_id($link)); mysqli_close($link); if (NULL !== ($tmp = mysqli_thread_id($link))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_thread_id(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_thread_safe.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_thread_safe.phpt +++ php-src/ext/mysqli/tests/mysqli_thread_safe.phpt --TEST-- mysqli_thread_safe() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php if (!is_bool($tmp = mysqli_thread_safe())) printf("[001] Expecting boolean/any, got %s/%s.\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_use_result.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_use_result.phpt +++ php-src/ext/mysqli/tests/mysqli_use_result.phpt --TEST-- mysqli_use_result() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_use_result())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_use_result($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id")) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_object($res = mysqli_use_result($link))) printf("[004] Expecting object, got %s/%s. [%d] %s\n", gettype($res), $res, mysqli_errno($link), mysqli_error($link)); if (false !== ($tmp = mysqli_data_seek($res, 2))) printf("[005] Expecting boolean/true, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link)); mysqli_free_result($res); if (!mysqli_query($link, "DELETE FROM test")) printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (false !== ($res = mysqli_use_result($link))) printf("[007] Expecting boolean/false, got %s/%s. [%d] %s\n", gettype($res), $res, mysqli_errno($link), mysqli_error($link)); if (!$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id")) printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (false !== ($tmp = mysqli_data_seek($res, 1))) printf("[009] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); if (NULL !== ($tmp = mysqli_use_result($link))) printf("[010] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_data_seek(): Function cannot be used with MYSQL_USE_RESULT in %s on line %d Warning: mysqli_use_result(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_warning_count.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_warning_count.phpt +++ php-src/ext/mysqli/tests/mysqli_warning_count.phpt --TEST-- mysqli_warning_count() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_warning_count())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_warning_count($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (NULL !== ($tmp = @mysqli_warning_count($link, "too_many"))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$res = mysqli_query($link, "SELECT id, label FROM test")) printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (0 !== ($tmp = mysqli_warning_count($link))) printf("[005] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, "DROP TABLE IF EXISTS this_table_does_not_exist")) printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (1 !== ($tmp = mysqli_warning_count($link))) printf("[007] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); if (NULL !== ($tmp = mysqli_warning_count($link))) printf("[010] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_warning_count(): Couldn't fetch mysqli in %s on line %d done!
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_autocommit.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/mysqli/tests/mysqli_autocommit.phpt diff -u php-src/ext/mysqli/tests/mysqli_autocommit.phpt:1.1 php-src/ext/mysqli/tests/mysqli_autocommit.phpt:1.2 --- php-src/ext/mysqli/tests/mysqli_autocommit.phpt:1.1 Thu Jul 12 20:20:57 2007 +++ php-src/ext/mysqli/tests/mysqli_autocommit.phpt Mon Jul 23 12:38:40 2007 @@ -146,7 +146,7 @@ if (NULL !== ($tmp = @mysqli_autocommit($link, false))) printf("[033] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); - print "done!\n"; + print "done!"; ?> --EXPECTF-- done! \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_autocommit_oo.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/mysqli/tests/mysqli_autocommit_oo.phpt diff -u php-src/ext/mysqli/tests/mysqli_autocommit_oo.phpt:1.1 php-src/ext/mysqli/tests/mysqli_autocommit_oo.phpt:1.2 --- php-src/ext/mysqli/tests/mysqli_autocommit_oo.phpt:1.1 Thu Jul 12 20:20:57 2007 +++ php-src/ext/mysqli/tests/mysqli_autocommit_oo.phpt Mon Jul 23 12:38:40 2007 @@ -135,7 +135,7 @@ if (NULL !== ($tmp = @$mysqli->autocommit( false))) printf("[030] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); - print "done!\n"; + print "done!"; ?> --EXPECTF-- done! \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_change_user.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_change_user.phpt +++ php-src/ext/mysqli/tests/mysqli_change_user.phpt --TEST-- mysqli_change_user() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_change_user())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_change_user($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_change_user($link, $link))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_change_user($link, $link, $link))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_change_user($link, $link, $link, $link, $link))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[006] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (false !== ($tmp = mysqli_change_user($link, $user . '_unknown_really', $passwd . 'non_empty', $db))) printf("[007] Expecting false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysqli_change_user($link, $user, $passwd . '_unknown_really', $db))) printf("[008] Expecting false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysqli_change_user($link, $user, $passwd, $db . '_unknown_really'))) printf("[009] Expecting false, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, 'SET @mysqli_change_user_test_var=1')) printf("[010] Failed to set test variable: [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$res = mysqli_query($link, 'SELECT @mysqli_change_user_test_var AS test_var')) printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); if (1 != $tmp['test_var']) printf("[012] Cannot set test variable\n"); if (true !== ($tmp = mysqli_change_user($link, $user, $passwd, $db))) printf("[013] Expecting true, got %s/%s\n", gettype($tmp), $tmp); if (!$res = mysqli_query($link, 'SELECT database() AS dbname, user() AS user')) printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); if (substr($tmp['user'], 0, strlen($user)) !== $user) printf("[015] Expecting user %s, got user() %s\n", $user, $tmp['user']); if ($tmp['dbname'] != $db) printf("[016] Expecting database %s, got database() %s\n", $db, $tmp['dbname']); if (!$res = mysqli_query($link, 'SELECT @mysqli_change_user_test_var AS test_var')) printf("[017] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); if (NULL !== $tmp['test_var']) printf("[019] Test variable is still set!\n"); mysqli_close($link); if (NULL !== ($tmp = @mysqli_change_user($link, $user, $passwd, $db))) printf("[020] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_change_user_oo.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_change_user_oo.phpt +++ php-src/ext/mysqli/tests/mysqli_change_user_oo.phpt --TEST-- mysqli->change_user() --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('table.inc'); if (!$IS_MYSQLND && (mysqli_get_server_version($link) < 50118 && mysqli_get_server_version($link) > 50100)) { die("skip Your MySQL Server version has a known but that will cause a crash"); } ?> --FILE-- <?php include_once("connect.inc"); $link = NULL; $tmp = NULL; if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (!is_null($tmp = @$mysqli->change_user())) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @$mysqli->change_user($link))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @$mysqli->change_user($link, $link))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @$mysqli->change_user($link, $link, $link, $link))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = $mysqli->change_user($user . '_unknown_really', $passwd . 'non_empty', $db))) printf("[006] Expecting false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = $mysqli->change_user($user, $passwd . '_unknown_really', $db))) printf("[007] Expecting false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = $mysqli->change_user($user, $passwd, $db . '_unknown_really'))) printf("[008] Expecting false, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query('SET @mysqli_change_user_test_var=1')) printf("[009] Failed to set test variable: [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$res = $mysqli->query('SELECT @mysqli_change_user_test_var AS test_var')) printf("[010] [%d] %s\n", $mysqli->errno, $mysqli->error); $tmp = $res->fetch_assoc(); $res->free_result(); if (1 != $tmp['test_var']) printf("[011] Cannot set test variable\n"); if (true !== ($tmp = $mysqli->change_user($user, $passwd, $db))) printf("[012] Expecting true, got %s/%s\n", gettype($tmp), $tmp); if (!$res = $mysqli->query('SELECT database() AS dbname, user() AS user')) printf("[013] [%d] %s\n", $mysqli->errno, $mysqli->error); $tmp = $res->fetch_assoc(); $res->free_result(); if (substr($tmp['user'], 0, strlen($user)) !== $user) printf("[014] Expecting user %s, got user() %s\n", $user, $tmp['user']); if ($tmp['dbname'] != $db) printf("[015] Expecting database %s, got database() %s\n", $db, $tmp['dbname']); if (!$res = $mysqli->query('SELECT @mysqli_change_user_test_var AS test_var')) printf("[016] [%d] %s\n", $mysqli->errno, $mysqli->error); $tmp = $res->fetch_assoc(); $res->free_result(); if (NULL !== $tmp['test_var']) printf("[017] Test variable is still set!\n"); $mysqli->close(); if (NULL !== ($tmp = @$mysqli->change_user($user, $passwd, $db))) printf("[018] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_character_set.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_character_set.phpt +++ php-src/ext/mysqli/tests/mysqli_character_set.phpt --TEST-- Fetching results from tables of different charsets. --SKIPIF-- <?php require_once('skipifunicode.inc'); ?> <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (ini_get("unicode.semantics")){ die('done!'); } if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (!$res = mysqli_query($link, 'SELECT version() AS server_version')) printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); $version = explode('.', $tmp['server_version']); if (empty($version)) printf("[003] Cannot determine server version, need MySQL Server 4.1+ for the test!\n"); if ($version[0] <= 4 && $version[1] < 1) printf("[004] Need MySQL Server 4.1+ for the test!\n"); if (!$res = mysqli_query($link, "SHOW CHARACTER SET")) printf("[005] Cannot get list of available character sets, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $charsets = array(); while ($row = mysqli_fetch_assoc($res)) $charsets[] = $row; mysqli_free_result($res); foreach ($charsets as $k => $charset) { /* The server currently 17.07.2007 can't handle data sent in ucs2 */ if ($charset['Charset'] == 'ucs2') { continue; } if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) printf("[006 + %d] [%d] %s\n", $k, mysqli_errno($link), mysqli_error($link)); $sql = sprintf("CREATE TABLE test(id INT, label CHAR(1)) CHARACTER SET '%s' ", $charset['Charset']); if (!mysqli_query($link, $sql)) { printf("[007 + %d] %s [%d] %s\n", $k, $sql, mysqli_errno($link), mysqli_error($link)); continue; } if (!mysqli_set_charset($link, $charset['Charset'])) { printf("[008 + %d] [%d] %s\n", $k, mysqli_errno($link), mysqli_error($link)); continue; } for ($i = 1; $i <= 3; $i++) { if (!mysqli_query($link, sprintf("INSERT INTO test (id, label) VALUES (%d, '%s')", $i, mysqli_real_escape_string($link, chr(ord("a") + $i))))) { var_dump($charset['Charset']); printf("[009 + %d] [%d] %s\n", $k, mysqli_errno($link), mysqli_error($link)); continue; } } if (!$res = mysqli_query($link, "SELECT id, label FROM test")) printf("[010 + %d] [%d] %s\n", $k, mysqli_errno($link), mysqli_error($link)); for ($i = 1; $i <= 3; $i++) { if (!$tmp = mysqli_fetch_assoc($res)) printf("[011 + %d] [%d] %s\n", $k, mysqli_errno($link), mysqli_error($link)); if ($tmp['id'] != $i) printf("[012 + %d] Expecting %d, got %s, [%d] %s\n", $k, $i, $tmp['id'], mysqli_errno($link), mysqli_error($link)); if ($tmp['label'] != chr(ord("a") + $i)) printf("[013 + %d] Expecting %d, got %s, [%d] %s\n", $k, chr(ord("a") + $i), $tmp['label'], mysqli_errno($link), mysqli_error($link)); } mysqli_free_result($res); } mysqli_close($link); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_character_set_name.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_character_set_name.phpt +++ php-src/ext/mysqli/tests/mysqli_character_set_name.phpt --TEST-- mysqli_chararcter_set_name(), mysql_client_encoding() [alias] --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php /* NOTE: http://bugs.mysql.com/bug.php?id=7923 makes this test fail very likely on all 4.1.x - 5.0.x! */ include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_character_set_name())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_character_set_name($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_character_set_name($link, $link, $link))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[005] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (!$res = mysqli_query($link, 'SELECT version() AS server_version')) printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); $version = explode('.', $tmp['server_version']); if (empty($version)) printf("[006] Cannot determine server version, need MySQL Server 4.1+ for the test!\n"); if ($version[0] <= 4 && $version[1] < 1) printf("[007] Need MySQL Server 4.1+ for the test!\n"); if (!$res = mysqli_query($link, 'SELECT @@character_set_connection AS charset, @@collation_connection AS collation')) printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); if (!$tmp['charset']) printf("[009] Cannot determine current character set and collation\n"); $charset = mysqli_character_set_name($link); if ($tmp['charset'] !== $charset) { if ($tmp['collation'] === $charset) { printf("[010] Could be known server bug http://bugs.mysql.com/bug.php?id=7923, collation %s instead of character set returned, expected string/%s, got %s/%s\n", $tmp['collation'], $tmp['charset'], gettype($charset), $charset); } else { printf("[011] Expecting character set %s/%s, got %s/%s\n", gettype($tmp['charset']), $tmp['charset'], gettype($charset), $charset); } } $charset2 = mysqli_client_encoding($link); if ($charset2 !== $charset) { printf("[012] Alias mysqli_client_encoding returned %s/%s, expected %s/%s\n", gettype($charset2), $charset2, gettype($charset), $charset); } mysqli_close($link); if (NULL !== ($tmp = @mysqli_character_set_name($link))) printf("[013] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); /* Make sure that the function alias exists */ if (!is_null($tmp = @mysqli_client_encoding())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_character_set_name_oo.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_character_set_name_oo.phpt +++ php-src/ext/mysqli/tests/mysqli_character_set_name_oo.phpt --TEST-- mysqli_chararcter_set_name(), mysql_client_encoding() [alias] --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php /* NOTE: http://bugs.mysql.com/bug.php?id=7923 makes this test fail very likely on all 4.1.x - 5.0.x! */ include "connect.inc"; $tmp = NULL; $link = NULL; if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (!is_null($tmp = @$mysqli->character_set_name($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$res = $mysqli->query('SELECT version() AS server_version')) printf("[003] [%d] %s\n", $mysqli->errno, $mysqli->error); $tmp = $res->fetch_assoc(); $res->free_result(); $version = explode('.', $tmp['server_version']); if (empty($version)) printf("[006] Cannot determine server version, need MySQL Server 4.1+ for the test!\n"); if ($version[0] <= 4 && $version[1] < 1) printf("[007] Need MySQL Server 4.1+ for the test!\n"); if (!$res = $mysqli->query('SELECT @@character_set_connection AS charset, @@collation_connection AS collation')) printf("[008] [%d] %s\n", $mysqli->errno, $mysqli->error); $tmp = $res->fetch_assoc(); $res->free_result(); if (!$tmp['charset']) printf("[009] Cannot determine current character set and collation\n"); $charset = $mysqli->character_set_name(); if ($tmp['charset'] !== $charset) { if ($tmp['collation'] === $charset) { printf("[010] Could be known server bug http://bugs.mysql.com/bug.php?id=7923, collation %s instead of character set returned, expected string/%s, got %s/%s\n", $tmp['collation'], $tmp['charset'], gettype($charset), $charset); } else { printf("[011] Expecting character set %s/%s, got %s/%s\n", gettype($tmp['charset']), $tmp['charset'], gettype($charset), $charset); } } $charset2 = $mysqli->character_set_name(); if ($charset2 !== $charset) { printf("[012] Alias mysqli_client_encoding returned %s/%s, expected %s/%s\n", gettype($charset2), $charset2, gettype($charset), $charset); } $mysqli->close(); if (NULL !== ($tmp = @$mysqli->character_set_name())) printf("[013] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); /* Make sure that the function alias exists */ if (!is_null($tmp = @$mysqli->client_encoding())) printf("[014] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_close.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_close.phpt +++ php-src/ext/mysqli/tests/mysqli_close.phpt --TEST-- mysqli_close() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_close())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_close($link, $link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_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 = @mysqli_close(NULL); if (NULL !== $tmp) printf("[004] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); $tmp = mysqli_close($link); if (true !== $tmp) printf("[005] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_query($link, "SELECT 1"))) printf("[006] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_close_oo.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_close_oo.phpt +++ php-src/ext/mysqli/tests/mysqli_close_oo.phpt --TEST-- mysqli_close() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (!is_null($tmp = @$mysqli->close($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); $tmp = $mysqli->close(); if (true !== $tmp) printf("[003] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @$mysqli->close())) printf("[004] Expecting NULL got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @$mysqli->query("SELECT 1"))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_commit.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_commit.phpt +++ php-src/ext/mysqli/tests/mysqli_commit.phpt --TEST-- mysqli_commit() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> <?PHP if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { die(sprintf("skip Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket)); } if (!$res = mysqli_query($link, "SHOW VARIABLES LIKE 'have_innodb'")) { die(sprintf("skip Cannot fetch have_innodb variable\n")); } $row = mysqli_fetch_row($res); mysqli_free_result($res); mysqli_close($link); if ($row[1] == "DISABLED" || $row[1] == "NO") { die(sprintf ("skip Innodb support is not installed or enabled.")); } ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_commit())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_commit($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_commit($link, $link))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_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 (true !== ($tmp = mysqli_autocommit($link, false))) printf("[005] Cannot turn off autocommit, expecting true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, 'CREATE TABLE test(id INT) ENGINE = InnoDB')) printf("[007] Cannot create test table, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, 'INSERT INTO test(id) VALUES (1)')) printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_commit($link); if ($tmp !== true) printf("[009] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, 'ROLLBACK')) printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$res = mysqli_query($link, 'SELECT COUNT(*) AS num FROM test')) printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); if (1 != $tmp['num']) printf("[12] Expecting 1 row in table test, found %d rows\n", $tmp['num']); mysqli_free_result($res); if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_close($link); if (NULL !== ($tmp = @mysqli_commit($link))) printf("[014] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_commit_oo.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_commit_oo.phpt +++ php-src/ext/mysqli/tests/mysqli_commit_oo.phpt --TEST-- mysqli_commit() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> <?PHP if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) { die(sprintf("skip Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket)); } if (!$res = $mysqli->query("SHOW VARIABLES LIKE 'have_innodb'")) { die(sprintf("skip Cannot fetch have_innodb variable\n")); } $row = $res->fetch_row(); $res->free(); $mysqli->close(); if ($row[1] == "DISABLED" || $row[1] == "NO") { die(sprintf("skip Innodb support is not installed or enabled.")); } ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; $mysqli = new mysqli(); if (!is_null($tmp = @$mysqli->commit())) printf("[013] Expecting NULL got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (!is_null($tmp = @$mysqli->commit($link))) printf("[002] Expecting NULL/NULL, got %s/%s, [%d] %s\n", gettype($tmp), $tmp, $mysqli->errno, $mysqli->error); if (true !== ($tmp = $mysqli->commit())) printf("[014] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = $mysqli->autocommit(false))) printf("[003] Cannot turn off autocommit, expecting true, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query('DROP TABLE IF EXISTS test')) printf("[004] [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$mysqli->query('CREATE TABLE test(id INT) ENGINE = InnoDB')) printf("[005] Cannot create test table, [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$mysqli->query('INSERT INTO test(id) VALUES (1)')) printf("[006] [%d] %s\n", $mysqli->errno, $mysqli->error); $tmp = $mysqli->commit(); if ($tmp !== true) printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query('ROLLBACK')) printf("[008] [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$res = $mysqli->query('SELECT COUNT(*) AS num FROM test')) printf("[009] [%d] %s\n", $mysqli->errno, $mysqli->error); $tmp = $res->fetch_assoc(); if (1 != $tmp['num']) printf("[010] Expecting 1 row in table test, found %d rows\n", $tmp['num']); $res->free(); if (!$mysqli->query('DROP TABLE IF EXISTS test')) printf("[011] [%d] %s\n", $mysqli->errno, $mysqli->error); $mysqli->close(); if (NULL !== ($tmp = @$mysqli->commit())) printf("[012] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_constants.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_constants.phpt +++ php-src/ext/mysqli/tests/mysqli_constants.phpt --TEST-- Constants exported by ext/mysqli --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php require("connect.inc"); require("table.inc"); $php_version = (int)str_replace('.', '', PHP_VERSION); $constants = get_defined_constants(true); sort($constants); $expected_constants = array( 'MYSQLI_READ_DEFAULT_GROUP' => true, 'MYSQLI_READ_DEFAULT_FILE' => true, 'MYSQLI_OPT_CONNECT_TIMEOUT' => true, 'MYSQLI_OPT_LOCAL_INFILE' => true, 'MYSQLI_INIT_COMMAND' => true, 'MYSQLI_CLIENT_SSL' => true, "MYSQLI_CLIENT_COMPRESS" => true, "MYSQLI_CLIENT_INTERACTIVE" => true, "MYSQLI_CLIENT_IGNORE_SPACE" => true, "MYSQLI_CLIENT_NO_SCHEMA" => true, "MYSQLI_CLIENT_FOUND_ROWS" => true, "MYSQLI_STORE_RESULT" => true, "MYSQLI_USE_RESULT" => true, "MYSQLI_ASSOC" => true, "MYSQLI_NUM" => true, "MYSQLI_BOTH" => true, "MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH" => true, "MYSQLI_NOT_NULL_FLAG" => true, "MYSQLI_PRI_KEY_FLAG" => true, "MYSQLI_UNIQUE_KEY_FLAG" => true, "MYSQLI_MULTIPLE_KEY_FLAG" => true, "MYSQLI_BLOB_FLAG" => true, "MYSQLI_UNSIGNED_FLAG" => true, "MYSQLI_ZEROFILL_FLAG" => true, "MYSQLI_AUTO_INCREMENT_FLAG" => true, "MYSQLI_TIMESTAMP_FLAG" => true, "MYSQLI_SET_FLAG" => true, "MYSQLI_NUM_FLAG" => true, "MYSQLI_PART_KEY_FLAG" => true, "MYSQLI_GROUP_FLAG" => true, "MYSQLI_TYPE_DECIMAL" => true, "MYSQLI_TYPE_TINY" => true, "MYSQLI_TYPE_SHORT" => true, "MYSQLI_TYPE_LONG" => true, "MYSQLI_TYPE_FLOAT" => true, "MYSQLI_TYPE_DOUBLE" => true, "MYSQLI_TYPE_NULL" => true, "MYSQLI_TYPE_TIMESTAMP" => true, "MYSQLI_TYPE_LONGLONG" => true, "MYSQLI_TYPE_INT24" => true, "MYSQLI_TYPE_DATE" => true, "MYSQLI_TYPE_TIME" => true, "MYSQLI_TYPE_DATETIME" => true, "MYSQLI_TYPE_YEAR" => true, "MYSQLI_TYPE_NEWDATE" => true, "MYSQLI_TYPE_ENUM" => true, "MYSQLI_TYPE_SET" => true, "MYSQLI_TYPE_TINY_BLOB" => true, "MYSQLI_TYPE_MEDIUM_BLOB" => true, "MYSQLI_TYPE_LONG_BLOB" => true, "MYSQLI_TYPE_BLOB" => true, "MYSQLI_TYPE_VAR_STRING" => true, "MYSQLI_TYPE_STRING" => true, "MYSQLI_TYPE_CHAR" => true, "MYSQLI_TYPE_INTERVAL" => true, "MYSQLI_TYPE_GEOMETRY" => true, "MYSQLI_NO_DATA" => true, "MYSQLI_REPORT_INDEX" => true, "MYSQLI_REPORT_STRICT" => true, "MYSQLI_REPORT_ALL" => true, "MYSQLI_REPORT_ERROR" => true, "MYSQLI_REPORT_OFF" => true, "MYSQLI_SET_CHARSET_NAME" => true, ); /* depends on the build - experimental */ if ($IS_MYSQLND && defined('MYSQLI_OPT_INT_AND_YEARS_AS_INT')) $expected_constants['MYSQLI_OPT_INT_AND_YEARS_AS_INT'] = true; if ($IS_MYSQLND) { $version = 50007 + 1; } else { $version = mysqli_get_client_version(); } if ($version > 50002) { $expected_constants = array_merge($expected_constants, array( "MYSQLI_TYPE_NEWDECIMAL" => true, "MYSQLI_TYPE_BIT" => true, )); } if ($version > 50003) { $expected_constants = array_merge($expected_constants, array( "MYSQLI_STMT_ATTR_CURSOR_TYPE" => true, "MYSQLI_CURSOR_TYPE_NO_CURSOR" => true, "MYSQLI_CURSOR_TYPE_READ_ONLY" => true, "MYSQLI_CURSOR_TYPE_FOR_UPDATE" => true, "MYSQLI_CURSOR_TYPE_SCROLLABLE" => true, )); } if ($version > 50007) { $expected_constants = array_merge($expected_constants, array( "MYSQLI_STMT_ATTR_PREFETCH_ROWS" => true, )); } /* pretty dump test, but that is the best way to mimic mysql.c */ if (defined('MYSQLI_DATA_TRUNCATED')) $expected_constants["MYSQLI_DATA_TRUNCATED"] = true; if ($IS_MYSQLND && $php_version >= 600) { /* mysqlnd only */ $expected_constants["MYSQLI_OPT_NUMERIC_AND_DATETIME_AS_UNICODE"] = true; } else if (!$IS_MYSQLND) { /* libmysql only */ /* are they available in all versions of ext/mysqli ? */ $expected_constants["MYSQLI_RPL_MASTER"] = true; $expected_constants["MYSQLI_RPL_SLAVE"] = true; $expected_constants["MYSQLI_RPL_ADMIN"] = true; } $unexpected_constants = array(); foreach ($constants as $group => $consts) { foreach ($consts as $name => $value) { if (stristr($name, 'mysqli')) { $name = strtoupper($name); if (isset($expected_constants[$name])) { unset($expected_constants[$name]); } else { $unexpected_constants[$name] = $name; } } } } if (!empty($unexpected_constants)) { printf("Dumping list of unexpected constants\n"); var_dump($unexpected_constants); } if (!empty($expected_constants)) { printf("Dumping list of missing constants\n"); var_dump($expected_constants); } print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_constants_categories.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_constants_categories.phpt +++ php-src/ext/mysqli/tests/mysqli_constants_categories.phpt --TEST-- Constants exported by ext/mysqli - checking category - PHP bug not mysqli bug (check from time to time) --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('connect.inc'); if (!$TEST_EXPERIMENTAL) die("skip This hits a known PHP bug, run the test from time to time and enable it once PHP got fixed"); ?> --FILE-- <?php require("connect.inc"); require("table.inc"); $constants = get_defined_constants(true); foreach ($constants as $group => $consts) { foreach ($consts as $name => $value) { if (stristr($name, 'mysqli')) { if ('mysqli' !== $group) printf("found constant '%s' in group '%s'. expecting group 'mysqli'\n", $name, $group); } } } print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_data_seek.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_data_seek.phpt +++ php-src/ext/mysqli/tests/mysqli_data_seek.phpt --TEST-- mysqli_data_seek() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (NULL !== ($tmp = @mysqli_data_seek())) printf("[001] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_data_seek($link))) printf("[002] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_data_seek($link, $link))) printf("[003] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysqli_query($link, 'SELECT * FROM test ORDER BY id LIMIT 4', MYSQLI_STORE_RESULT)) printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (true !== ($tmp = mysqli_data_seek($res, 3))) printf("[005] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); $row = mysqli_fetch_assoc($res); if (4 != $row['id']) printf("[006] Expecting record 4/d, got record %s/%s\n", $row['id'], $row['label']); if (true !== ($tmp = mysqli_data_seek($res, 0))) printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); $row = mysqli_fetch_assoc($res); if (1 != $row['id']) printf("[008] Expecting record 1/a, got record %s/%s\n", $row['id'], $row['label']); if (false !== ($tmp = mysqli_data_seek($res, 4))) printf("[009] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysqli_data_seek($res, -1))) printf("[010] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); mysqli_free_result($res); if (!$res = mysqli_query($link, 'SELECT * FROM test ORDER BY id', MYSQLI_USE_RESULT)) printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (false !== ($tmp = mysqli_data_seek($res, 3))) printf("[012] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); mysqli_free_result($res); if (NULL !== ($tmp = mysqli_data_seek($res, 1))) printf("[013] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); print "done!"; ?> --EXPECTF-- Warning: mysqli_data_seek(): Function cannot be used with MYSQL_USE_RESULT in %s on line %d Warning: mysqli_data_seek(): Couldn't fetch mysqli_result in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_data_seek_oo.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_data_seek_oo.phpt +++ php-src/ext/mysqli/tests/mysqli_data_seek_oo.phpt --TEST-- mysqli_result->data_seek() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; require('table.inc'); if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); $res = new mysqli_result($mysqli); if (NULL !== ($tmp = @$res->data_seek(0))) printf("[002] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$res = $mysqli->query('SELECT * FROM test ORDER BY id LIMIT 4', MYSQLI_STORE_RESULT)) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (NULL !== ($tmp = @$res->data_seek())) printf("[004] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @$res->data_seek($link))) printf("[005] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @$res->data_seek($link, $link))) printf("[006] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = $res->data_seek(3))) printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); $row = $res->fetch_assoc(); if (4 != $row['id']) printf("[008] Expecting record 4/d, got record %s/%s\n", $row['id'], $row['label']); if (true !== ($tmp = $res->data_seek(0))) printf("[009] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); $row = $res->fetch_assoc(); if (1 != $row['id']) printf("[010] Expecting record 1/a, got record %s/%s\n", $row['id'], $row['label']); if (false !== ($tmp = $res->data_seek(4))) printf("[011] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = $res->data_seek(-1))) printf("[012] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); $res->free_result(); if (!$res = $mysqli->query('SELECT * FROM test ORDER BY id', MYSQLI_USE_RESULT)) printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (false !== ($tmp = $res->data_seek(3))) printf("[014] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); $res->free_result(); if (NULL !== ($tmp = $res->data_seek(1))) printf("[015] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); $mysqli->close(); print "done!"; ?> --EXPECTF-- Warning: mysqli_result::data_seek(): Function cannot be used with MYSQL_USE_RESULT in %s on line %d Warning: mysqli_result::data_seek(): Couldn't fetch mysqli_result in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_debug.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_debug.phpt +++ php-src/ext/mysqli/tests/mysqli_debug.phpt --TEST-- mysqli_debug() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); if (!function_exists('mysqli_debug')) die("skip: mysqli_debug() not available"); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (NULL !== ($tmp = @mysqli_debug())) printf("[001] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); // NOTE: documentation is not clear on this: function always return NULL or TRUE if (true !== ($tmp = mysqli_debug("d:t:O,/tmp/client.trace"))) printf("[002] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_disable_reads_from_master.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_disable_reads_from_master.phpt +++ php-src/ext/mysqli/tests/mysqli_disable_reads_from_master.phpt --TEST-- mysqli_disable_reads_from_master() --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); if (!function_exists('mysqli_disable_reads_from_master')) { die("skip mysqli_disable_reads_from_master() not available"); } ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (NULL !== ($tmp = @mysqli_disable_reads_from_master())) printf("[001] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_disable_reads_from_master($link))) printf("[002] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_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); } if (!is_bool($tmp = mysqli_disable_reads_from_master($link))) printf("[004] Expecting boolean/[true|false] value, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); if (NULL !== ($tmp = mysqli_disable_reads_from_master($link))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_disable_reads_from_master(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_disable_rpl_parse.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_disable_rpl_parse.phpt +++ php-src/ext/mysqli/tests/mysqli_disable_rpl_parse.phpt --TEST-- mysqli_disable_rpl_parse() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> <?PHP if (!function_exists('mysqli_disable_rpl_parse')) die("skip mysqli_disable_rpl_parse() not available"); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (NULL !== ($tmp = @mysqli_disable_rpl_parse())) printf("[001] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_disable_rpl_parse($link))) printf("[002] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_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); } if (!is_bool($tmp = mysqli_disable_rpl_parse($link))) printf("[004] Expecting boolean/[true|false] value, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); if (NULL !== ($tmp = mysqli_disable_rpl_parse($link))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_disable_rpl_parse(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_driver.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_driver.phpt +++ php-src/ext/mysqli/tests/mysqli_driver.phpt --TEST-- mysqli_driver class --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; include "table.inc"; if (!is_object($driver = new mysqli_driver())) printf("[001] Failed to create mysqli_driver object\n"); $client_info = mysqli_get_client_info(); if (($tmp = $driver->client_info) !== $client_info) printf("[002] Expecting %s/%s, got %s/%s\n", gettype($client_info), $client_info, gettype($tmp), $tmp); $client_version = mysqli_get_client_version(); if (($tmp = $driver->client_version) !== $client_version) printf("[003] Expecting %s/%s, got %s/%s\n", gettype($client_version), $client_version, gettype($tmp), $tmp); if (!is_int($tmp = $driver->driver_version) || (0 == $tmp)) printf("[004] Expecting int/any, got %s/%s\n", gettype($tmp), $tmp); $all_modes = array(MYSQLI_REPORT_INDEX, MYSQLI_REPORT_ERROR, MYSQLI_REPORT_STRICT, MYSQLI_REPORT_ALL, MYSQLI_REPORT_OFF); $report_mode = $driver->report_mode; if (!is_int($report_mode)) printf("[005] Expecting int/any, got %s/%s\n", gettype($report_mode), $report_mode); if (!in_array($report_mode, $all_modes)) printf("[006] Illegal report mode returned? Got %s, expected %s\n", $report_mode, implode(', ', $all_modes)); $driver->report_mode = MYSQLI_REPORT_STRICT; $ok = false; try { if ($link = mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket)) printf("[007] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", $host, $user . 'unknown_really', $db, $port, $socket); mysqli_close($link); } catch (mysqli_sql_exception $e) { $ok = true; if ('' == $e->getMessage()) printf("[008] getMessage() has returned an emptry string.\n"); if ('' == $e->getCode()) printf("[009] getCode() has returned an empty string.\n"); if ('' == $e->getFile()) printf("[010] getFile() has returned an empty string.\n"); if ('' == $e->getLine()) printf("[011] getLine() has returned an empty string.\n"); $tmp = $e->getTrace(); if (empty($tmp)) printf("[012] getTrace() has returned an empty array.\n"); if ('' == $e->getTraceAsString()) printf("[013] getTraceAsString() has returned an empty string.\n"); if ('' == $e->__toString()) printf("[014] __toString() has returned an empty string.\n"); } if (!$ok) printf("[015] Error reporting mode has not been switched to exceptions and or no exception thrown\n"); $driver->report_mode = MYSQLI_REPORT_OFF; if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[016] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); mysqli_query($link, "NO_SQL"); mysqli_close($link); $driver->report_mode = MYSQLI_REPORT_ERROR; if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[017] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); mysqli_query($link, "NO_SQL"); mysqli_close($link); if (MYSQLI_REPORT_ERROR !== $driver->report_mode) printf("[018] Error mode should be different\n"); /* TODO - more report testing should go in here, but it's not really documented what behaviour is expected */ $driver->report_mode = $report_mode; $reconnect = $driver->reconnect; if (!is_bool($reconnect)) printf("[019] Expecting boolean/any, got %s/%s\n", gettype($reconnect), $reconnect); /* pointless, but I need more documentation */ $driver->reconnect = true; $driver->reconnect = false; $driver->reconnect = $reconnect; if (!is_bool($embedded = $driver->embedded)) printf("[020] Expecting boolean/any, got %s/%s\n", gettype($embedded), $embedded); print "done!"; ?> --EXPECTF-- Warning: mysqli_query(): (%d/%d): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NO_SQL' at line 1 in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_dump_debug_info.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_dump_debug_info.phpt +++ php-src/ext/mysqli/tests/mysqli_dump_debug_info.phpt --TEST-- mysqli_dump_debug_info() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (NULL !== ($tmp = @mysqli_dump_debug_info())) printf("[001] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_dump_debug_info($link))) printf("[002] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_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); exit(1); } if (!is_bool($tmp = mysqli_dump_debug_info($link))) printf("[004] Expecting boolean/[true|false] value, got %s/%s, [%d] %s\n", gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link)); mysqli_close($link); if (NULL !== ($tmp = mysqli_dump_debug_info($link))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link)); print "done!"; ?> --EXPECTF-- Warning: mysqli_dump_debug_info(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_dump_debug_info_oo.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_dump_debug_info_oo.phpt +++ php-src/ext/mysqli/tests/mysqli_dump_debug_info_oo.phpt --TEST-- mysqli_dump_debug_info() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (NULL !== ($tmp = @$mysqli->dump_debug_info($link))) printf("[002] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_bool($tmp = $mysqli->dump_debug_info())) printf("[003] Expecting boolean/[true|false] value, got %s/%s, [%d] %s\n", gettype($tmp), $tmp, $mysqli->errno, $mysqli->error); $mysqli->close(); if (NULL !== ($tmp = $mysqli->dump_debug_info())) printf("[004] Expecting NULL, got %s/%s, [%d] %s\n", gettype($tmp), $tmp, $mysqli->errno, $mysqli->error); print "done!"; ?> --EXPECTF-- Warning: mysqli::dump_debug_info(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_embedded_connect.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_embedded_connect.phpt +++ php-src/ext/mysqli/tests/mysqli_embedded_connect.phpt --TEST-- mysqli_embedded_connect() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifnotemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (NULL !== ($tmp = @mysqli_embedded_connect())) printf("[001] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_embedded_connect($db)) { 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 (!is_bool($tmp = mysqli_embedded_connect($db . '_unknown'))) printf("[003] Expecting boolean/[true|false] value, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); print "done!"; ?> --EXPECTF-- Warning: mysqli_embedded_connect() expects parameter 1 to be mysqli, null given in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_enable_reads_from_master.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_enable_reads_from_master.phpt +++ php-src/ext/mysqli/tests/mysqli_enable_reads_from_master.phpt --TEST-- mysqli_enable_reads_from_master() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> <?PHP if (!function_exists('mysqli_enable_reads_from_master')) { die("skip function mysqli_enable_reads_from_master() not available\n"); } ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (NULL !== ($tmp = @mysqli_enable_reads_from_master())) printf("[001] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_enable_reads_from_master($link))) printf("[002] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_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); } if (!is_bool($tmp = mysqli_enable_reads_from_master($link))) printf("[004] Expecting boolean/[true|false] value, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); if (NULL !== ($tmp = mysqli_enable_reads_from_master($link))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_enable_reads_from_master(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_enable_rpl_parse.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_enable_rpl_parse.phpt +++ php-src/ext/mysqli/tests/mysqli_enable_rpl_parse.phpt --TEST-- mysqli_enable_rpl_parse() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> <?PHP if (!function_exists('mysqli_enable_rpl_parse')) die("skip mysqli_enable_rpl_parse() not available"); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (NULL !== ($tmp = @mysqli_enable_rpl_parse())) printf("[001] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_enable_rpl_parse($link))) printf("[002] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_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); } if (!is_bool($tmp = mysqli_enable_rpl_parse($link))) printf("[004] Expecting boolean/[true|false] value, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); if (NULL !== ($tmp = mysqli_enable_rpl_parse($link))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_enable_rpl_parse(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_errno.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_errno.phpt +++ php-src/ext/mysqli/tests/mysqli_errno.phpt --TEST-- mysqli_errno() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_errno())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_errno($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_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); } var_dump(mysqli_errno($link)); if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) { printf("[004] Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } mysqli_query($link, 'SELECT * FROM test'); var_dump(mysqli_errno($link)); @mysqli_query($link, 'No SQL'); if (($tmp = mysqli_errno($link)) == 0) printf("[005] Expecting int/any non zero got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); var_dump(mysqli_errno($link)); print "done!"; ?> --EXPECTF-- int(0) int(%d) Warning: mysqli_errno(): Couldn't fetch mysqli in %s on line %d NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_errno_oo.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_errno_oo.phpt +++ php-src/ext/mysqli/tests/mysqli_errno_oo.phpt --TEST-- $mysqli->errno --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; $mysqli = new mysqli(); if (!is_null($tmp = @$mysqli->errno)) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli = new mysqli($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); var_dump($mysqli->errno); if (!$mysqli->query('DROP TABLE IF EXISTS test')) { printf("[003] Failed to drop old test table: [%d] %s\n", $mysqli->errno, $mysqli->error); } $mysqli->query('SELECT * FROM test'); var_dump($mysqli->errno); @$mysqli->query('No SQL'); if (($tmp = $mysqli->errno) === 0) printf("[004] Expecting int/any non zero got %s/%s\n", gettype($tmp), $tmp); $mysqli->close(); var_dump($mysqli->errno); print "done!"; ?> --EXPECTF-- int(0) int(%d) Warning: main(): Couldn't fetch mysqli in %s on line %d NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_error.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_error.phpt +++ php-src/ext/mysqli/tests/mysqli_error.phpt --TEST-- mysqli_error() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_error())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_error($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_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 = mysqli_error($link); if (!is_string($tmp) || ('' !== $tmp)) printf("[004] Expecting string/empty, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) { printf("[005] Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } mysqli_query($link, 'SELECT * FROM test'); $tmp = mysqli_error($link); if (!is_string($tmp) || !preg_match("/Table '\w*\.test' doesn't exist/su", $tmp)) printf("[006] Expecting string/[Table... doesn't exit], got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link)); mysqli_close($link); var_dump(mysqli_error($link)); print "done!"; ?> --EXPECTF-- Warning: mysqli_error(): Couldn't fetch mysqli in %s on line %d NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_error_oo.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_error_oo.phpt +++ php-src/ext/mysqli/tests/mysqli_error_oo.phpt --TEST-- $mysqli->error --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; $mysqli = new mysqli(); if (!is_null($tmp = @$mysqli->error)) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli = new mysqli($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); $tmp = $mysqli->error; if (!is_string($tmp) || ('' !== $tmp)) printf("[003] Expecting string/empty, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, $mysqli->errno, $mysqli->error); if (!$mysqli->query('DROP TABLE IF EXISTS test')) { printf("[004] Failed to drop old test table: [%d] %s\n", $mysqli->errno, $mysqli->error); } $mysqli->query('SELECT * FROM test'); $tmp = $mysqli->error; if (!is_string($tmp) || !preg_match("/Table '\w*\.test' doesn't exist/su", $tmp)) printf("[006] Expecting string/[Table... doesn't exit], got %s/%s. [%d] %s\n", gettype($tmp), $tmp, $mysqli->errno, $mysqli->error); $mysqli->close(); var_dump($mysqli->error); print "done!"; ?> --EXPECTF-- Warning: main(): Couldn't fetch mysqli in %s on line %d NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_error_unicode.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_error_unicode.phpt +++ php-src/ext/mysqli/tests/mysqli_error_unicode.phpt --TEST-- mysqli_error() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_error())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_error($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_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); } if (!ini_get("unicode.semantics")) { mysqli_query($link, "set names utf8"); } $tmp = mysqli_error($link); if (!is_string($tmp) || ('' !== $tmp)) printf("[004] Expecting string/empty, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link)); mysqli_query($link, 'SELECT * FROM нÑма_Ñакава_ÑаблиÑа'); $tmp = mysqli_error($link); var_dump(str_replace($db.".", "", $tmp)); mysqli_close($link); var_dump(mysqli_error($link)); print "done!"; ?> --EXPECTF-- string(58) "Table 'нÑма_Ñакава_ÑаблиÑа' doesn't exist" Warning: mysqli_error(): Couldn't fetch mysqli in %s on line %d NULL done! --UEXPECTF-- unicode(41) "Table 'нÑма_Ñакава_ÑаблиÑа' doesn't exist" Warning: mysqli_error(): Couldn't fetch mysqli in %s on line %d NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_explain_metadata.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_explain_metadata.phpt +++ php-src/ext/mysqli/tests/mysqli_explain_metadata.phpt --TEST-- EXPLAIN - metadata --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php require_once('connect.inc'); require_once('table.inc'); if (!$res = mysqli_query($link, 'EXPLAIN SELECT t1.*, t2.* FROM test AS t1, test AS t2')) printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $num_rows = 0; $num_fields = 0; $field_names = array(); if (!$row = mysqli_fetch_assoc($res)) { printf("[002] Expecting result but got no data [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } else { $num_rows++; $num_fields = count($row); foreach ($row as $name => $value) $field_names[$name] = gettype($value); } while ($row = mysqli_fetch_assoc($res)) $num_rows++; if (($tmp = mysqli_num_rows($res)) !== $num_rows) { printf("[003] Expecting int/%d got %s/%s\n", $num_rows, gettype($tmp), $tmp); } if (($tmp = mysqli_field_count($link)) !== $num_fields) { printf("[004] Expecting int/%d got %s/%s\n", $num_fields, gettype($tmp), $tmp); } $fields = mysqli_fetch_fields($res); if (($tmp = count($fields)) !== $num_fields) { printf("[005] Expecting int/%d got %s/%s\n", $num_fields, gettype($tmp), $tmp); } foreach ($fields as $k => $field) { $field->max_length = 0;// change it or we will get diff error if (isset($field_names[$field->name])) { unset($field_names[$field->name]); } else { printf("[006] Unexpected field '%s', dumping info\n"); var_dump($field); } } if (!empty($field_names)) { printf("[007] Field descriptions missing for the following columns\n"); var_dump($field_names); } mysqli_free_result($res); $stmt = mysqli_stmt_init($link); /* Depending on your version, the MySQL server migit not support this */ if ($stmt->prepare('EXPLAIN SELECT t1.*, t2.* FROM test AS t1, test AS t2') && $stmt->execute()) { if (!mysqli_stmt_store_result($stmt)) printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!$res_meta = mysqli_stmt_result_metadata($stmt)) printf("[009] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (($tmp = mysqli_stmt_num_rows($stmt)) !== $num_rows) { printf("[010] Expecting int/%d got %s/%s\n", $num_rows, gettype($tmp), $tmp); } if (($tmp = mysqli_stmt_field_count($stmt)) !== $num_fields) { printf("[011] Expecting int/%d got %s/%s\n", $num_fields, gettype($tmp), $tmp); } if (($tmp = mysqli_field_count($link)) !== $num_fields) { printf("[013] Expecting int/%d got %s/%s\n", $num_fields, gettype($tmp), $tmp); } if (($tmp = $res_meta->field_count) !== $num_fields) { printf("[014] Expecting int/%d got %s/%s\n", $num_fields, gettype($tmp), $tmp); } $fields_res_meta = mysqli_fetch_fields($res_meta); if (($tmp = count($fields_res_meta)) !== $num_fields) printf("[015] Expecting int/%d got %s/%s\n", $num_fields, gettype($tmp), $tmp); if ($fields_res_meta != $fields) { printf("[016] Prepared Statement metadata differs from normal metadata, dumping\n"); var_dump($fields_res_meta); var_dump($fields); } if (function_exists('mysqli_stmt_get_result') && $stmt->prepare('EXPLAIN SELECT t1.*, t2.* FROM test AS t1, test AS t2') && $stmt->execute()) { if (!$res_stmt = mysqli_stmt_get_result($stmt)) { printf("[017] Cannot fetch result from PS [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); } if (($tmp = mysqli_num_rows($res_stmt)) !== $num_rows) { printf("[018] Expecting int/%d got %s/%s\n", $num_rows, gettype($tmp), $tmp); } if ((mysqli_stmt_num_rows($stmt)) !== 0) { printf("[019] Expecting int/0 got %s/%s\n", gettype($tmp), $tmp); } if (($tmp = mysqli_stmt_field_count($stmt)) !== $num_fields) { printf("[020] Expecting int/%d got %s/%s\n", $num_fields, gettype($tmp), $tmp); } if (($tmp = $res_stmt->field_count) !== $num_fields) { printf("[021] Expecting int/%d got %s/%s\n", $num_fields, gettype($tmp), $tmp); } $fields_stmt = mysqli_fetch_fields($res_stmt); if (($tmp = count($fields_stmt)) !== $num_fields) { printf("[022] Expecting int/%d got %s/%s\n", $num_fields, gettype($tmp), $tmp); } reset($fields); foreach ($fields_stmt as $fields_stmt_val) { list(,$fields_val) = each($fields); unset($fields_stmt_val->max_length); unset($fields_val->max_length); if ($fields_stmt_val != $fields_val) { printf("[023] PS mysqli_stmt_get_result() metadata seems wrong, dumping\n"); var_dump($fields_stmt_val); var_dump($fields_val); } } /* if ($fields_stmt != $fields) { printf("[023] PS mysqli_stmt_get_result() metadata seems wrong, dumping\n"); var_dump($fields_stmt); var_dump($fields); } */ mysqli_free_result($res_stmt); } } mysqli_stmt_close($stmt); mysqli_close($link); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_fetch_lengths.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_fetch_lengths.phpt +++ php-src/ext/mysqli/tests/mysqli_fetch_lengths.phpt --TEST-- mysqli_fetch_lengths() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) printf("[001] Cannot connect\n"); if (!is_null($tmp = @mysqli_fetch_lengths())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_fetch_lengths($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id LIMIT 1")) { printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } var_dump(mysqli_fetch_lengths($res)); while ($row = mysqli_fetch_assoc($res)) var_dump(mysqli_fetch_lengths($res)); var_dump(mysqli_fetch_lengths($res)); mysqli_free_result($res); var_dump(mysqli_fetch_lengths($res)); mysqli_close($link); print "done!"; ?> --EXPECTF-- bool(false) array(2) { [0]=> int(1) [1]=> int(1) } bool(false) Warning: mysqli_fetch_lengths(): Couldn't fetch mysqli_result in %s on line %d NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_fetch_lengths_oo.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_fetch_lengths_oo.phpt +++ php-src/ext/mysqli/tests/mysqli_fetch_lengths_oo.phpt --TEST-- mysqli_result->lengths --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) printf("[001] Cannot connect\n"); require('table.inc'); if (!$res = $mysqli->query("SELECT id, label FROM test ORDER BY id LIMIT 1")) { printf("[002] [%d] %s\n", $mysqli->errno, $mysqli->error); } var_dump($res->lengths); while ($row = $res->fetch_assoc()) var_dump($res->lengths); var_dump($res->lengths); $res->free_result(); var_dump($res->lengths); $mysqli->close(); print "done!"; ?> --EXPECTF-- NULL array(2) { [0]=> int(1) [1]=> int(1) } NULL Warning: main(): Couldn't fetch mysqli_result in %s on line %d NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_field_count.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_field_count.phpt +++ php-src/ext/mysqli/tests/mysqli_field_count.phpt --TEST-- mysqli_field_count() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_field_count())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_field_count($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); var_dump(mysqli_field_count($link)); if (!$res = mysqli_query($link, "SELECT * FROM test ORDER BY id LIMIT 1")) { printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } var_dump(mysqli_field_count($link)); mysqli_free_result($res); if (!mysqli_query($link, "INSERT INTO test(id, label) VALUES (100, 'x')")) printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump($link->field_count); var_dump(mysqli_field_count($link)); if (!$res = mysqli_query($link, 'SELECT NULL as _null, "" AS "", "three" AS "drei"')) printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump(mysqli_field_count($link)); mysqli_free_result($res); mysqli_close($link); var_dump(mysqli_field_count($link)); print "done!"; ?> --EXPECTF-- int(0) int(2) int(0) int(0) int(3) Warning: mysqli_field_count(): Couldn't fetch mysqli in %s on line %d NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_field_seek.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_field_seek.phpt +++ php-src/ext/mysqli/tests/mysqli_field_seek.phpt --TEST-- mysqli_field_seek() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php function mysqli_field_seek_flags($flags) { $ret = ''; if ($flags & MYSQLI_NOT_NULL_FLAG) $ret .= 'MYSQLI_NOT_NULL_FLAG '; if ($flags & MYSQLI_PRI_KEY_FLAG) $ret .= 'MYSQLI_PRI_KEY_FLAG '; if ($flags & MYSQLI_UNIQUE_KEY_FLAG) $ret .= 'MYSQLI_UNIQUE_KEY_FLAG '; if ($flags & MYSQLI_MULTIPLE_KEY_FLAG) $ret .= 'MYSQLI_MULTIPLE_KEY_FLAG '; if ($flags & MYSQLI_BLOB_FLAG) $ret .= 'MYSQLI_BLOB_FLAG '; if ($flags & MYSQLI_UNSIGNED_FLAG) $ret .= 'MYSQLI_UNSIGNED_FLAG '; if ($flags & MYSQLI_ZEROFILL_FLAG) $ret .= 'MYSQLI_ZEROFILL_FLAG '; if ($flags & MYSQLI_AUTO_INCREMENT_FLAG) $ret .= 'MYSQLI_AUTO_INCREMENT_FLAG '; if ($flags & MYSQLI_TIMESTAMP_FLAG) $ret .= 'MYSQLI_TIMESTAMP_FLAG '; if ($flags & MYSQLI_SET_FLAG) $ret .= 'MYSQLI_SET_FLAG '; if ($flags & MYSQLI_NUM_FLAG) $ret .= 'MYSQLI_NUM_FLAG '; if ($flags & MYSQLI_PART_KEY_FLAG) $ret .= 'MYSQLI_PART_KEY_FLAG '; if ($flags & MYSQLI_GROUP_FLAG) $ret .= 'MYSQLI_GROUP_FLAG '; return $ret; } include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_field_seek())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_field_seek($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id LIMIT 1", MYSQLI_USE_RESULT)) { printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } var_dump(mysqli_field_seek($res, -1)); var_dump(mysqli_fetch_field($res)); var_dump(mysqli_field_seek($res, 0)); var_dump(mysqli_fetch_field($res)); var_dump(mysqli_field_seek($res, 1)); var_dump(mysqli_fetch_field($res)); var_dump(mysqli_field_tell($res)); var_dump(mysqli_field_seek($res, 2)); var_dump(mysqli_fetch_field($res)); var_dump(mysqli_field_seek($res, PHP_INT_MAX + 1)); if (!is_null($tmp = @mysqli_field_seek($res, 0, "too many"))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_free_result($res); if (!$res = mysqli_query($link, "SELECT NULL as _null", MYSQLI_STORE_RESULT)) { printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } var_dump(mysqli_field_seek($res, 0)); var_dump(mysqli_fetch_field($res)); mysqli_free_result($res); var_dump(mysqli_field_seek($res, 0)); mysqli_close($link); print "done!"; ?> --EXPECTF-- Warning: mysqli_field_seek(): Invalid field offset in %s on line %d bool(false) object(stdClass)#%d (11) { ["name"]=> string(2) "id" ["orgname"]=> string(2) "id" ["table"]=> string(4) "test" ["orgtable"]=> string(4) "test" ["def"]=> string(0) "" ["max_length"]=> int(0) ["length"]=> int(11) ["charsetnr"]=> int(63) ["flags"]=> int(49155) ["type"]=> int(3) ["decimals"]=> int(0) } bool(true) object(stdClass)#%d (11) { ["name"]=> string(2) "id" ["orgname"]=> string(2) "id" ["table"]=> string(4) "test" ["orgtable"]=> string(4) "test" ["def"]=> string(0) "" ["max_length"]=> int(0) ["length"]=> int(11) ["charsetnr"]=> int(63) ["flags"]=> int(49155) ["type"]=> int(3) ["decimals"]=> int(0) } bool(true) object(stdClass)#%d (11) { ["name"]=> string(5) "label" ["orgname"]=> string(5) "label" ["table"]=> string(4) "test" ["orgtable"]=> string(4) "test" ["def"]=> string(0) "" ["max_length"]=> int(0) ["length"]=> int(1) ["charsetnr"]=> int(8) ["flags"]=> int(0) ["type"]=> int(254) ["decimals"]=> int(0) } int(2) Warning: mysqli_field_seek(): Invalid field offset in %s on line %d bool(false) bool(false) Warning: mysqli_field_seek(): Invalid field offset in %s on line %d bool(false) bool(true) object(stdClass)#3 (11) { ["name"]=> string(5) "_null" ["orgname"]=> string(0) "" ["table"]=> string(0) "" ["orgtable"]=> string(0) "" ["def"]=> string(0) "" ["max_length"]=> int(0) ["length"]=> int(0) ["charsetnr"]=> int(63) ["flags"]=> int(32896) ["type"]=> int(6) ["decimals"]=> int(0) } Warning: mysqli_field_seek(): Couldn't fetch mysqli_result in %s on line %d NULL done! --UEXPECTF-- Warning: mysqli_field_seek(): Invalid field offset in %s on line %d bool(false) object(stdClass)#%d (11) { [u"name"]=> unicode(2) "id" [u"orgname"]=> unicode(2) "id" [u"table"]=> unicode(4) "test" [u"orgtable"]=> unicode(4) "test" [u"def"]=> unicode(0) "" [u"max_length"]=> int(%d) [u"length"]=> int(%d) [u"charsetnr"]=> int(%d) [u"flags"]=> int(%d) [u"type"]=> int(%d) [u"decimals"]=> int(0) } bool(true) object(stdClass)#%d (11) { [u"name"]=> unicode(2) "id" [u"orgname"]=> unicode(2) "id" [u"table"]=> unicode(4) "test" [u"orgtable"]=> unicode(4) "test" [u"def"]=> unicode(0) "" [u"max_length"]=> int(%d) [u"length"]=> int(%d) [u"charsetnr"]=> int(%d) [u"flags"]=> int(%d) [u"type"]=> int(%d) [u"decimals"]=> int(0) } bool(true) object(stdClass)#%d (11) { [u"name"]=> unicode(5) "label" [u"orgname"]=> unicode(5) "label" [u"table"]=> unicode(4) "test" [u"orgtable"]=> unicode(4) "test" [u"def"]=> unicode(0) "" [u"max_length"]=> int(%d) [u"length"]=> int(%d) [u"charsetnr"]=> int(%d) [u"flags"]=> int(%d) [u"type"]=> int(%d) [u"decimals"]=> int(0) } int(2) Warning: mysqli_field_seek(): Invalid field offset in %s on line %d bool(false) bool(false) Warning: mysqli_field_seek(): Invalid field offset in %s on line %d bool(false) bool(true) object(stdClass)#3 (11) { [u"name"]=> unicode(5) "_null" [u"orgname"]=> unicode(0) "" [u"table"]=> unicode(0) "" [u"orgtable"]=> unicode(0) "" [u"def"]=> unicode(0) "" [u"max_length"]=> int(0) [u"length"]=> int(0) [u"charsetnr"]=> int(63) [u"flags"]=> int(32896) [u"type"]=> int(6) [u"decimals"]=> int(0) } Warning: mysqli_field_seek(): Couldn't fetch mysqli_result in %s on line %d NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_field_tell.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_field_tell.phpt +++ php-src/ext/mysqli/tests/mysqli_field_tell.phpt --TEST-- mysqli_field_tell() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_field_tell())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_field_tell($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysqli_query($link, "SELECT id FROM test ORDER BY id LIMIT 1", MYSQLI_USE_RESULT)) { printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } var_dump(mysqli_field_tell($res)); var_dump(mysqli_field_seek(1)); var_dump(mysqli_field_tell($res)); var_dump(mysqli_fetch_field($res)); var_dump(mysqli_fetch_field($res)); var_dump(mysqli_field_tell($res)); if (!is_null($tmp = @mysqli_field_tell($res, 'too many arguments'))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); var_dump(mysqli_field_seek($res, 2)); var_dump(mysqli_field_tell($res)); var_dump(mysqli_field_seek($res, -1)); var_dump(mysqli_field_tell($res)); var_dump(mysqli_field_seek($res, 0)); var_dump(mysqli_field_tell($res)); mysqli_free_result($res); var_dump(mysqli_field_tell($res)); mysqli_close($link); print "done!"; ?> --EXPECTF-- int(0) Warning: mysqli_field_seek() expects exactly 2 parameters, 1 given in %s on line %d NULL int(0) object(stdClass)#%d (11) { ["name"]=> string(2) "id" ["orgname"]=> string(2) "id" ["table"]=> string(4) "test" ["orgtable"]=> string(4) "test" ["def"]=> string(0) "" ["max_length"]=> int(0) ["length"]=> int(11) ["charsetnr"]=> int(63) ["flags"]=> int(49155) ["type"]=> int(3) ["decimals"]=> int(0) } bool(false) int(1) Warning: mysqli_field_seek(): Invalid field offset in %s on line %d bool(false) int(1) Warning: mysqli_field_seek(): Invalid field offset in %s on line %d bool(false) int(1) bool(true) int(0) Warning: mysqli_field_tell(): Couldn't fetch mysqli_result in %s on line %d NULL done! --UEXPECTF-- int(0) Warning: mysqli_field_seek() expects exactly 2 parameters, 1 given in %s on line %d NULL int(0) object(stdClass)#%d (11) { [u"name"]=> unicode(2) "id" [u"orgname"]=> unicode(2) "id" [u"table"]=> unicode(4) "test" [u"orgtable"]=> unicode(4) "test" [u"def"]=> unicode(0) "" [u"max_length"]=> int(%d) [u"length"]=> int(%d) [u"charsetnr"]=> int(%d) [u"flags"]=> int(%d) [u"type"]=> int(%d) [u"decimals"]=> int(0) } bool(false) int(1) Warning: mysqli_field_seek(): Invalid field offset in %s on line %d bool(false) int(1) Warning: mysqli_field_seek(): Invalid field offset in %s on line %d bool(false) int(1) bool(true) int(0) Warning: mysqli_field_tell(): Couldn't fetch mysqli_result in %s on line %d NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_free_result.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_free_result.phpt +++ php-src/ext/mysqli/tests/mysqli_free_result.phpt --TEST-- mysqli_free_result() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $db = 'test'; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_free_result())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_free_result($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysqli_query($link, "SELECT id FROM test ORDER BY id LIMIT 1")) { printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } print "a\n"; var_dump(mysqli_free_result($res)); print "b\n"; var_dump(mysqli_free_result($res)); if (!$res = mysqli_query($link, "SELECT id FROM test ORDER BY id LIMIT 1")) { printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } print "c\n"; var_dump($res = mysqli_store_result($link)); var_dump(mysqli_error($link)); print "[005]\n"; var_dump(mysqli_free_result($res)); if (!$res = mysqli_query($link, "SELECT id FROM test ORDER BY id LIMIT 1")) { printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } print "d\n"; var_dump($res = mysqli_use_result($link)); var_dump(mysqli_error($link)); print "[007]\n"; var_dump(mysqli_free_result($res)); mysqli_close($link); print "done!"; ?> --EXPECTF-- a NULL b Warning: mysqli_free_result(): Couldn't fetch mysqli_result in %s on line %d NULL c bool(false) %s(0) "" [005] Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, boolean given in %s on line %d NULL d bool(false) %s(0) "" [007] Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, boolean given in %s on line %d NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_charset.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_charset.phpt +++ php-src/ext/mysqli/tests/mysqli_get_charset.phpt --TEST-- mysqli_get_charset() --SKIPIF-- <?php require_once('skipifemb.inc'); require_once('skipif.inc'); if (!function_exists('mysqli_get_charset')) die("skip: function not available"); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_get_charset())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_get_charset($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_set_charset($link, $link))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysqli_query($link, 'SELECT version() AS server_version')) printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_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 = mysqli_query($link, 'SELECT @@character_set_connection AS charset, @@collation_connection AS collation')) printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); if (!($character_set_connection = $tmp['charset']) || !($collation_connection = $tmp['collation'])) printf("[008] Cannot determine current character set and collation\n"); if (!$res = mysqli_query($link, $sql = sprintf('SHOW CHARACTER SET LIKE "%s"', $character_set_connection))) printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); if (empty($tmp)) printf("[010] Cannot fetch Maxlen and/or Comment, test will fail: $sql\n"); $maxlen = (isset($tmp['Maxlen'])) ? $tmp['Maxlen'] : ''; $comment = (isset($tmp['Description'])) ? $tmp['Description'] : ''; if (!$res = mysqli_query($link, sprintf('SHOW COLLATION LIKE "%s"', $collation_connection))) printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); if (!($id = $tmp['Id'])) printf("[012] Cannot fetch Id/Number, test will fail\n"); if (!$res = mysqli_query($link, sprintf('SHOW VARIABLES LIKE "character_sets_dir"'))) printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); if (!($character_sets_dir = $tmp['Value'])) printf("[014] Cannot fetch character_sets_dir, test will fail\n"); if (!is_object($charset = mysqli_get_charset($link))) printf("[015] Expecting object/std_class, got %s/%s\n", gettype($charset), $charset); if (!isset($charset->charset) || !in_array(gettype($charset->charset), array("string", "unicode")) || ($character_set_connection !== $charset->charset)) printf("[016] Expecting string/%s, got %s/%s\n", $character_set_connection, gettype($charset->charset), $charset->charset); if (!isset($charset->collation) || !in_array(gettype($charset->collation), array("string", "unicode")) || ($collation_connection !== $charset->collation)) printf("[017] Expecting string/%s, got %s/%s\n", $collation_connection, gettype($charset->collation), $charset->collation); if (!isset($charset->dir) || !is_string($charset->dir)) printf("[019] Expecting string - ideally %s*, got %s/%s\n", $character_sets_dir, gettype($charset->dir), $charset->dir); if (!isset($charset->min_length) || !(is_int($charset->min_length)) || ($charset->min_length < 0) || ($charset->min_length > $charset->max_length)) printf("[020] Expecting int between 0 ... %d, got %s/%s\n", $charset->max_length, gettype($charset->min_length), $charset->min_length); if (!isset($charset->number) || !is_int($charset->number) || ($charset->number !== (int)$id)) printf("[021] Expecting int/%d, got %s/%s\n", $id, gettype($charset->number), $charset->number); if (!isset($charset->state) || !is_int($charset->state)) printf("[022] Expecting int/any, got %s/%s\n", gettype($charset->state), $charset->state); mysqli_close($link); if (NULL !== ($tmp = mysqli_get_charset($link))) printf("[023] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_get_charset(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_client_info.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_client_info.phpt +++ php-src/ext/mysqli/tests/mysqli_get_client_info.phpt --TEST-- mysqli_get_client_info() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; if (!is_string($info = mysqli_get_client_info()) || ('' === $info)) printf("[001] Expecting string/any_non_empty, got %s/%s\n", gettype($info), $info); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_client_version.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_client_version.phpt +++ php-src/ext/mysqli/tests/mysqli_get_client_version.phpt --TEST-- mysqli_get_client_version() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; if (!is_int($info = mysqli_get_client_version()) || ($info < 100)) printf("[001] Expecting int/any_non_empty, got %s/%s\n", gettype($info), $info); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_connection_stats.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_connection_stats.phpt +++ php-src/ext/mysqli/tests/mysqli_get_connection_stats.phpt --TEST-- mysqli_get_connection_stats() --SKIPIF-- <?PHP require_once('skipif.inc'); require_once('skipifemb.inc'); if (!function_exists('mysqli_get_connection_stats')) { die("skip only available with mysqlnd"); } ?> --FILE-- <?php $tmp = $link = null; if (!is_null($tmp = @mysqli_get_connection_stats())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_get_connection_stats($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); include "connect.inc"; include "table.inc"; if (!is_array($info = mysqli_get_connection_stats($link)) || empty($info)) printf("[003] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info); if (!is_array($info2 = mysqli_get_client_stats()) || empty($info2)) printf("[004] Expecting array/any_non_empty, got %s/%s\n", gettype($info2), $info2); if ($info !== $info2) { printf("[005] The hashes should be identical\n"); var_dump($info); var_dump($info2); } mysqli_close($link); include "table.inc"; if (!is_array($info = mysqli_get_connection_stats($link)) || empty($info)) printf("[006] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info); if (!is_array($info2 = mysqli_get_client_stats()) || empty($info2)) printf("[007] Expecting array/any_non_empty, got %s/%s\n", gettype($info2), $info2); // assuming the test is run in a plain-vanilla CLI environment if ($info === $info2) { printf("[008] The hashes should not be identical\n"); var_dump($info); var_dump($info2); } print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_host_info.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_host_info.phpt +++ php-src/ext/mysqli/tests/mysqli_get_host_info.phpt --TEST-- mysqli_get_host_info() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; if (!is_null($tmp = @mysqli_get_host_info())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_get_host_info(NULL))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require "table.inc"; if (!is_string($info = mysqli_get_host_info($link)) || ('' === $info)) printf("[003] Expecting string/any_non_empty, got %s/%s\n", gettype($info), $info); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_proto_info.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_proto_info.phpt +++ php-src/ext/mysqli/tests/mysqli_get_proto_info.phpt --TEST-- mysqli_get_proto_info() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; if (!is_null($tmp = @mysqli_get_proto_info())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_get_proto_info(NULL))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require "table.inc"; if (!is_int($info = mysqli_get_proto_info($link)) || ($info < 1)) printf("[003] Expecting int/any_non_empty, got %s/%s\n", gettype($info), $info); if (!is_null($tmp = @mysqli_get_proto_info('too many', 'arguments'))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_server_info.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_server_info.phpt +++ php-src/ext/mysqli/tests/mysqli_get_server_info.phpt --TEST-- mysqli_get_server_info() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; if (!is_null($tmp = @mysqli_get_server_info())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_get_server_info(NULL))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require "table.inc"; if (!is_string($info = mysqli_get_server_info($link)) || ('' === $info)) printf("[003] Expecting string/any_non_empty, got %s/%s\n", gettype($info), $info); if (!is_null($tmp = @mysqli_get_server_info('too', 'many arguments'))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_server_version.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_server_version.phpt +++ php-src/ext/mysqli/tests/mysqli_get_server_version.phpt --TEST-- mysqli_get_server_version() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; if (!is_null($tmp = @mysqli_get_server_version())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_get_server_version(NULL))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require "table.inc"; /* 5.1.5 -> 50105 -- major_version*10000 + minor_version *100 + sub_version */ /* < 30000 = pre 3.2.3, very unlikely! */ if (!is_int($info = mysqli_get_server_version($link)) || ($info < (3 * 10000))) printf("[003] Expecting int/any >= 30000, got %s/%s\n", gettype($info), $info); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_warnings.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_warnings.phpt +++ php-src/ext/mysqli/tests/mysqli_get_warnings.phpt --TEST-- mysqli_get_warnings() - TODO --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('connect.inc'); if (!$TEST_EXPERIMENTAL) die("skip - experimental (= unsupported) feature"); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_get_warnings())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_get_warnings($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_get_warnings(''))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { printf("[003] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); } if (false !== ($tmp = mysqli_get_warnings($link))) { printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), (is_object($tmp) ? var_dump($tmp, true) : $tmp)); } if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, "CREATE TABLE test (id SMALLINT)")) printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, "INSERT INTO test (id) VALUES (1000000)")) printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_object($warning = mysqli_get_warnings($link)) || 'mysqli_warning' != get_class($warning)) { printf("[008] Expecting object/mysqli_warning, got %s/%s\n", gettype($tmp), (is_object($tmp) ? var_dump($tmp, true) : $tmp)); } if (!method_exists($warning, 'next')) printf("[009] Borked object, method next is missing\n"); $properties = array_merge(get_object_vars($warning), get_class_vars(get_class($warning))); if (!empty($properties)) printf("[010] Properties have always been magic, hidden things - why are they visible now, a BC break...\n"); if ((!is_string($warning->message)) || ('' == $warning->message)) /* NULL or not there at all */ printf("[011] Expecting string/not empty, got %s/%s\n", gettype($warning->message), $warning->message); if ((!is_string($warning->sqlstate)) || ('' == $warning->sqlstate)) /* NULL or not there at all */ printf("[012] Expecting string/not empty, got %s/%s\n", gettype($warning->sqlstate), $warning->sqlstate); if ((!is_int($warning->errno)) || (0 == $warning->errno)) /* NULL or not there at all */ printf("[013] Expecting int/not 0, got %s/%s\n", gettype($warning->errno), $warning->errno); if (false !== ($tmp = $warning->next())) printf("[014] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, "INSERT INTO test (id) VALUES (1000000), (1000001)")) printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (($tmp = mysqli_warning_count($link)) !== 2) printf("[016] Expecting 2 warnings, got %d warnings", $tmp); if (!is_object($warning = mysqli_get_warnings($link)) || 'mysqli_warning' != get_class($warning)) { printf("[017] Expecting object/mysqli_warning, got %s/%s\n", gettype($tmp), (is_object($tmp) ? var_dump($tmp, true) : $tmp)); } if (true !== ($tmp = $warning->next())) printf("[018] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = $warning->next())) printf("[020] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) printf("[021] Cannot create mysqli object: [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); if (!$mysqli->query("DROP TABLE IF EXISTS t1")) printf("[022] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$mysqli->query("CREATE TABLE t1 (a smallint)")) printf("[023] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_object($warning = new mysqli_warning($mysqli))) printf("[024] Expecting object/mysqli_warning, got %s/%s", gettype($warning), $warning); if (!is_string($warning->message) || ('' == $warning->message)) printf("[025] Expecting string, got %s/%s", gettype($warning->message), $warning->message); if (!$mysqli->query("DROP TABLE t1")) printf("[026] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); /* Yes, I really want to check if the object property is empty */ if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) printf("[027] Cannot create mysqli object: [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); $warning = new mysqli_warning($mysqli); if (false !== ($tmp = $warning->next())) printf("[028] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if ('' != ($tmp = $warning->message)) printf("[029] Expecting string/empty, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) printf("[030] Cannot create mysqli object: [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); if (!$mysqli->query("DROP TABLE IF EXISTS t1")) printf("[031] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$mysqli->query("CREATE TABLE t1 (a smallint)")) printf("[032] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); /* out of range, three warnings */ if (!$mysqli->query("INSERT IGNORE INTO t1(a) VALUES (65536), (65536), (65536)")) printf("[033] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $warning = new mysqli_warning($mysqli); $i = 1; while ($warning->next() && ('' != ($tmp = $warning->message))) { if (ini_get('unicode.semantics') && !is_unicode($tmp)) printf("[033a] Warning should have been a unicode string, got %s/%s", gettype($tmp), $tmp); $i++; } if (3 != $i) printf("[034] Expecting three warnings, got %d warnings\n", $i); $stmt = mysqli_stmt_init(); $warning = new mysqli_warning($stmt); if (false !== ($tmp = $warning->next())) printf("[035] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_info.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_info.phpt +++ php-src/ext/mysqli/tests/mysqli_info.phpt --TEST-- mysqli_info() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; if (!is_null($tmp = @mysqli_info())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_info(NULL))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require "table.inc"; if (!$res = mysqli_query($link, 'INSERT INTO test(id, label) VALUES (100, "a")')) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); // NOTE: empty string, no multiple insert syntax if (!is_string($tmp = mysqli_info($link)) || ('' != $tmp)) printf("[004] Expecting string/empty, got %s/%s\n", gettype($tmp), $tmp); if (!$res = mysqli_query($link, 'INSERT INTO test(id, label) VALUES (101, "a"), (102, "b")')) printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_string($tmp = mysqli_info($link)) || ('' == $tmp)) printf("[006] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp); if (ini_get('unicode.semantics') && !is_unicode($tmp)) printf("[007] Expecting unicode, because unicode mode it on. Got binary string\n"); if (!$res = mysqli_query($link, 'INSERT INTO test(id, label) SELECT id + 200, label FROM test')) printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_string($tmp = mysqli_info($link)) || ('' == $tmp)) printf("[008] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp); if (!$res = mysqli_query($link, 'ALTER TABLE test MODIFY label CHAR(2)')) printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_string($tmp = mysqli_info($link)) || ('' == $tmp)) printf("[010] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp); if (!$res = mysqli_query($link, 'UPDATE test SET label = "b" WHERE id >= 100')) printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_string($tmp = mysqli_info($link)) || ('' == $tmp)) printf("[012] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp); if (!$res = mysqli_query($link, "SELECT 1")) printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_string($tmp = mysqli_info($link)) || ('' != $tmp)) printf("[014] Expecting string/empty, got %s/%s\n", gettype($tmp), $tmp); mysqli_free_result($res); // NOTE: no LOAD DATA INFILE test if ($dir = sys_get_temp_dir()) { do { $file = $dir . '/' . 'mysqli_info_phpt.cvs'; if (!$fp = fopen($file, 'w')) /* ignore this error */ break; if (!fwrite($fp, b"100;'a';\n") || !fwrite($fp, b"101;'b';\n") || !fwrite($fp, b"102;'c';\n")) { @unlink($file); break; } fclose($fp); if (!mysqli_query($link, "DELETE FROM test")) { printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); break; } if (!@mysqli_query($link, sprintf("LOAD DATA LOCAL INFILE '%s' INTO TABLE test FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '\'' LINES TERMINATED BY '\n'", $file))) { /* ok, because we might not be allowed to do this */ @unlink($file); break; } if (!is_string($tmp = mysqli_info($link)) || ('' == $tmp)) printf("[015] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp); unlink($file); } while (false); } print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_init.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_init.phpt +++ php-src/ext/mysqli/tests/mysqli_init.phpt --TEST-- mysqli_init() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php $link = mysqli_init(); if (!is_object($link) && false !== $link) printf("[001] Expecting object/mysqli_link or boolean/false, got %s/%s\n", gettype($link), $link); if (is_object($link) && 'mysqli' != get_class($link)) printf("[002] Expecting object of type mysqli got object of type %s\n", get_class($link)); if ($link) mysqli_close($link); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_insert_id.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_insert_id.phpt +++ php-src/ext/mysqli/tests/mysqli_insert_id.phpt --TEST-- mysqli_insert_id() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_insert_id())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_insert_id($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (0 !== ($tmp = mysqli_insert_id($link))) printf("[003] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); if (!$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id LIMIT 1")) { printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } if (0 !== ($tmp = mysqli_insert_id($link))) printf("[005] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); mysqli_free_result($res); // no auto_increment column if (!$res = mysqli_query($link, "INSERT INTO test(id, label) VALUES (100, 'a')")) { printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } if (0 !== ($tmp = mysqli_insert_id($link))) printf("[007] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); if (!$res = mysqli_query($link, "ALTER TABLE test MODIFY id INT NOT NULL AUTO_INCREMENT")) { printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } if (!$res = mysqli_query($link, "INSERT INTO test(label) VALUES ('a')")) { printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } if (($last_id = mysqli_insert_id($link)) <= 0) printf("[010] Expecting int/any >0, got %s/%s\n", gettype($last_id), $last_id); if (mysqli_query($link, "LOCK TABLE test WRITE")) { /* we need exclusive access for a moment */ /* let's hope nobody changes auto_increment_increment while this code executes */ do { if (mysqli_get_server_version($link) >= 50000) { if (!$res = mysqli_query($link, 'SELECT @@auto_increment_increment AS inc')) { printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); break; } if (!$row = mysqli_fetch_assoc($res)) { printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); break; } mysqli_free_result($res); $inc = $row['inc']; } else { $inc = 1; } if (!mysqli_query($link, "INSERT INTO test(label) VALUES ('b')")) { printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); break; } if (($next_id = mysqli_insert_id($link)) <= $last_id) /* very likely a bug, but someone could have done something on the server between the second last insert and the lock, therefore don't stop just bail */ printf("[014] Expecting int/any > %d, got %s/%s\n", $last_id, gettype($next_id), $next_id); $last_id = $next_id; if (!mysqli_query($link, "INSERT INTO test(label) VALUES ('c'), ('d'), ('e')")) { printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); break; } /* Note: For a multiple-row insert, LAST_INSERT_ID() and mysql_insert_id() actually return the AUTO_INCREMENT key from the first of the inserted rows. This allows multiple-row inserts to be reproduced correctly on other servers in a replication setup. */ if (($next_id = mysqli_insert_id($link)) != $last_id + $inc) { printf("[016] Expecting int/%d, got %s/%s\n", $last_id + 1, gettype($next_id), $next_id); break; } if (!$res = mysqli_query($link, "SELECT LAST_INSERT_ID() AS last_id")) { printf("[017] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); break; } if (!$row = mysqli_fetch_assoc($res)) { printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); break; } mysqli_free_result($res); if ($next_id != $row['last_id']) { printf("[018] Something is wrong, check manually. Expecting %s got %s.\n", $next_id, $row['last_id']); break; } } while (false); mysqli_query($link, "UNLOCK TABLE test"); } mysqli_close($link); var_dump(mysqli_insert_id($link)); print "done!"; ?> --EXPECTF-- Warning: mysqli_insert_id(): Couldn't fetch mysqli in %s on line %d NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_kill.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_kill.phpt +++ php-src/ext/mysqli/tests/mysqli_kill.phpt --TEST-- mysqli_kill() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_kill())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_kill($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); // Zend will cast the NULL to 0 if (!is_bool($tmp = mysqli_kill($link, null))) printf("[003] Expecting boolean/any, got %s/%s\n", gettype($tmp), $tmp); if (!$thread_id = mysqli_thread_id($link)) printf("[004] Cannot determine thread id, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_kill($link, $thread_id); if (!is_bool($tmp)) printf("[005] Expecting boolean/any, got %s/%s\n", gettype($tmp), $tmp); if ($res = mysqli_query($link, "SELECT id FROM test LIMIT 1")) pintf("[006] Expecting boolean/false, got %s/%s\n", gettype($res), $res); var_dump($error = mysqli_error($link)); if (!is_string($error) || ('' === $error)) printf("[007] Expecting string/any non empty, got %s/%s\n", gettype($error), $error); var_dump($res); var_dump($link); mysqli_close($link); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[008] Cannot connect, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); mysqli_kill($link, -1); if ((!$res = mysqli_query($link, "SELECT id FROM test LIMIT 1")) || (!$tmp = mysqli_fetch_assoc($res))) { printf("[009] Connection should not be gone, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } var_dump($tmp); mysqli_free_result($res); mysqli_close($link); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[010] Cannot connect, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); mysqli_change_user($link, "This might work if you accept anonymous users in your setup", "password", $db); mysqli_kill($link, -1); mysqli_close($link); print "done!"; ?> --EXPECTF-- Warning: mysqli_kill(): processid should have positive value in %s on line %d string(%d) "%s" bool(false) object(mysqli)#%d (0) { } Warning: mysqli_kill(): processid should have positive value in %s on line %d array(1) { ["id"]=> string(1) "1" } Warning: mysqli_kill(): processid should have positive value in %s on line %d done! --UEXPECTF-- Warning: mysqli_kill(): processid should have positive value in %s on line %d unicode(%d) "%s" bool(false) object(mysqli)#%d (0) { } Warning: mysqli_kill(): processid should have positive value in %s on line %d array(1) { [u"id"]=> unicode(1) "1" } Warning: mysqli_kill(): processid should have positive value in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_more_results.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_more_results.phpt +++ php-src/ext/mysqli/tests/mysqli_more_results.phpt --TEST-- mysqli_more_results() --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $strict_on = false; if (defined('E_STRICT')) { error_reporting(((int)ini_get('error_reporting')) | E_STRICT ); $strict_on = true; } $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_more_results())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_more_results($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); print "[004]\n"; var_dump(mysqli_more_results($link)); if (!mysqli_multi_query($link, "SELECT 1 AS a; SELECT 1 AS a, 2 AS b; SELECT id FROM test ORDER BY id LIMIT 3")) printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); print "[006]\n"; $i = 1; if ($strict_on) ob_start(); if (mysqli_get_server_version($link) > 41000 && !($ret = mysqli_more_results($link))) printf("[007] Expecting boolean/true, got %s/%s\n", gettype($ret), $ret); do { $res = mysqli_store_result($link); mysqli_free_result($res); if (mysqli_more_results($link)) printf("%d\n", $i++); } while (mysqli_next_result($link)); if ($strict_on) { $tmp = ob_get_contents(); ob_end_clean(); if (!preg_match('@Strict Standards: mysqli_next_result\(\): There is no next result set@ismU', $tmp)) { printf("[008] Strict Standards warning missing\n"); } else { $tmp = trim(preg_replace('@Strict Standards: mysqli_next_result\(\).*on line \d+@ism', '', $tmp)); } print trim($tmp) . "\n"; } if (!mysqli_multi_query($link, "SELECT 1 AS a; SELECT 1 AS a, 2 AS b; SELECT id FROM test ORDER BY id LIMIT 3")) printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); print "[010]\n"; $i = 1; if (mysqli_get_server_version($link) > 41000 && !($ret = mysqli_more_results($link))) printf("[011] Expecting boolean/true, got %s/%s\n", gettype($ret), $ret); if ($strict_on) ob_start(); do { $res = mysqli_use_result($link); // NOTE: if you use mysqli_use_result() with mysqli_more_results() or any other info function, // you must fetch all rows before you can loop to the next result set! // See also the MySQL Reference Manual: mysql_use_result() while ($row = mysqli_fetch_array($res)) ; mysqli_free_result($res); if (mysqli_more_results($link)) printf("%d\n", $i++); } while (mysqli_next_result($link)); if ($strict_on) { $tmp = ob_get_contents(); ob_end_clean(); if (!preg_match('@Strict Standards: mysqli_next_result\(\): There is no next result set@ismU', $tmp)) { printf("[008] Strict Standards warning missing\n"); } else { $tmp = trim(preg_replace('@Strict Standards: mysqli_next_result\(\).*on line \d+@ism', '', $tmp)); } print trim($tmp) . "\n"; } mysqli_close($link); var_dump(mysqli_more_results($link)); print "done!"; ?> --EXPECTF-- [004] bool(false) [006] 1 2 [010] 1 2 Warning: mysqli_more_results(): Couldn't fetch mysqli in %s on line %d NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_multi_query.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_multi_query.phpt +++ php-src/ext/mysqli/tests/mysqli_multi_query.phpt --TEST-- mysqli_multi_query() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $strict_on = false; if (defined('E_STRICT')) { error_reporting(((int)ini_get('error_reporting')) | E_STRICT ); $strict_on = true; } $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_multi_query())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_multi_query($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (false !== ($tmp = mysqli_multi_query($link, ""))) printf("[003] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_multi_query($link, "SELECT 1 AS a; SELECT 1 AS a, 2 AS b; SELECT id FROM test ORDER BY id LIMIT 3")) printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if ($strict_on) ob_start(); $i = 0; do { $res = mysqli_store_result($link); while ($row = mysqli_fetch_array($res)) ; mysqli_free_result($res); $i++; } while (mysqli_next_result($link)); if ($strict_on) { $tmp = ob_get_contents(); ob_end_clean(); if (!preg_match('@Strict Standards: mysqli_next_result\(\): There is no next result set@ismU', $tmp)) { printf("[005a] Strict Standards warning missing\n"); } else { $tmp = trim(preg_replace('@Strict Standards: mysqli_next_result\(\).*on line \d+@ism', '', $tmp)); } print trim($tmp) . "\n"; } printf("[006] %d\n", $i); if (!mysqli_multi_query($link, "ALTER TABLE test MODIFY id INT AUTO_INCREMENT; INSERT INTO test(label) VALUES ('a'); SELECT id, label FROM test ORDER BY id")) printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $i = 0; while (mysqli_next_result($link) && ($res = mysqli_store_result($link))) { while ($row = mysqli_fetch_array($res)) ; mysqli_free_result($res); printf("%d/%d\n", $i, mysqli_insert_id($link)); $i++; } printf("[008] %d\n", $i); if (!mysqli_multi_query($link, "SELECT id, label FROM test")) printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if ($strict_on) ob_start(); $i = 0; while (mysqli_next_result($link) && ($res = mysqli_store_result($link))) { while ($row = mysqli_fetch_array($res)) $i++; mysqli_free_result($res); } if ($strict_on) { $tmp = ob_get_contents(); ob_end_clean(); if (!preg_match('@Strict Standards: mysqli_next_result\(\): There is no next result set@ismU', $tmp)) { printf("[009a] Strict Standards warning missing\n"); } else { $tmp = trim(preg_replace('@Strict Standards: mysqli_next_result\(\).*on line \d+@ism', '', $tmp)); } print trim($tmp) . "\n"; } printf("[010] %d\n", $i); if (!mysqli_multi_query($link, "SELECT 1 AS num, 'a' AS somechar; SELECT 2 AS num, 'a' AS somechar; SELECT 3 AS num, 'a' AS somechar")) printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $res_num = 1; do { if (!$res = mysqli_store_result($link)) { printf("[012 - %d] [%d] %s\n", $res_num, mysqli_errno($link), mysqli_error($link)); continue; } $num_rows = 0; while ($row = mysqli_fetch_array($res)) { $num_rows++; if ($row['num'] != $res_num) printf("[013 - %d] Expecting %s got %s\n", $res_num, $res_num, $row['num']); if ($row['somechar'] != "a") printf("[014 - %d] Expecting a got %s\n", $res_num, $row['somechar']); if (1 == $num_rows) { /* simple metadata check */ if (!($lengths = mysqli_fetch_lengths($res))) printf("[015 - %d] [%d] %s\n", $res_num, mysqli_errno($link), mysqli_error($link)); if (count($lengths) != 2) printf("[016 - %d] Expecting 2 column lengths got %d [%d] %s\n", $res_num, count($lengths)); foreach ($lengths as $k => $length) if ($length <= 0) printf("[017 - %d] Strange column lengths for column %d, got %d expecting any > 0\n", $res_num, $k, $length); } } if ($num_rows != 1) printf("[018 - %d] Expecting 1 row, got %d rows\n", $num_rows); $res_num++; mysqli_free_result($res); } while (@mysqli_next_result($link)); if ($res_num != 4) printf("[015] Expecting 3 result sets got %d result set[s]\n", $res_num); mysqli_close($link); var_dump(mysqli_multi_query($link, "SELECT id, label FROM test")); print "done!"; ?> --EXPECTF-- [006] 3 [008] 0 [009] [2014] Commands out of sync; you can't run this command now [010] 7 Warning: mysqli_multi_query(): Couldn't fetch mysqli in %s on line %d NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_mysqli_result_invalid_mode.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_mysqli_result_invalid_mode.phpt +++ php-src/ext/mysqli/tests/mysqli_mysqli_result_invalid_mode.phpt --TEST-- mysqli_result(), invalid mode --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php require('connect.inc'); require('table.inc'); $valid = array(MYSQLI_STORE_RESULT, MYSQLI_USE_RESULT); do { $mode = mt_rand(-1000, 1000); } while (in_array($mode, $valid)); if (!is_object($res = new mysqli_result($link, $mode))) printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); print "done!"; ?> --EXPECTF-- Warning: mysqli_result::mysqli_result(): Invalid value for resultmode in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_next_result.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_next_result.phpt +++ php-src/ext/mysqli/tests/mysqli_next_result.phpt --TEST-- mysqli_next_result() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $strict_on = false; if (defined('E_STRICT')) { error_reporting(((int)ini_get('error_reporting')) | E_STRICT ); $strict_on = true; } $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_next_result())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_next_result($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if ($strict_on) ob_start(); if (false !== ($tmp = mysqli_next_result($link))) printf("[003] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if ($strict_on) { $tmp = ob_get_contents(); ob_end_clean(); if (!preg_match('@Strict Standards: mysqli_next_result\(\): There is no next result set@ismU', $tmp)) { printf("[003a] Strict Standards warning missing\n"); } else { $tmp = trim(preg_replace('@Strict Standards: mysqli_next_result\(\).*on line \d+@ism', '', $tmp)); } print trim($tmp) . "\n"; ob_start(); } $res = mysqli_query($link, "SELECT 1 AS res"); if (false !== ($tmp = mysqli_next_result($link))) printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if ($strict_on) { $tmp = ob_get_contents(); ob_end_clean(); if (!preg_match('@Strict Standards: mysqli_next_result\(\): There is no next result set@ismU', $tmp)) { printf("[004a] Strict Standards warning missing\n"); } else { $tmp = trim(preg_replace('@Strict Standards: mysqli_next_result\(\).*on line \d+@ism', '', $tmp)); } print trim($tmp) . "\n"; } mysqli_free_result($res); function func_test_mysqli_next_result($link, $query, $offset, $num_results, $strict_on) { if (!mysqli_multi_query($link, $query)) printf("[%03d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link)); $i = 0; if ($strict_on) ob_start(); do { if ($res = mysqli_store_result($link)) { mysqli_free_result($res); $i++; } } while (true === mysqli_next_result($link)); if ($strict_on) { $tmp = ob_get_contents(); ob_end_clean(); if (!preg_match('@Strict Standards: mysqli_next_result\(\): There is no next result set@ismU', $tmp)) { printf("[%03d] Strict Standards warning missing\n", $offset + 1); } else { $tmp = trim(preg_replace('@Strict Standards: mysqli_next_result\(\).*on line \d+@ism', '', $tmp)); } print trim($tmp) . "\n"; } if ($i !== $num_results) { printf("[%03d] Expecting %d result(s), got %d result(s)\n", $offset + 2, $num_results, $i); } if (mysqli_more_results($link)) printf("[%03d] mysqli_more_results() indicates more results than expected\n", $offset + 3); if (!($res = mysqli_query($link, "SELECT 1 AS b"))) { printf("[%03d] [%d] %s\n", $offset + 4, mysqli_errno($link), mysqli_error($link)); } else { mysqli_free_result($res); } } func_test_mysqli_next_result($link, "SELECT 1 AS a; SELECT 1 AS a, 2 AS b; SELECT id FROM test ORDER BY id LIMIT 3", 5, 3, $strict_on); func_test_mysqli_next_result($link, "SELECT 1 AS a; INSERT INTO test(id, label) VALUES (100, 'y'); SELECT 1 AS a, 2 AS b", 8, 2, $strict_on); func_test_mysqli_next_result($link, "DELETE FROM test WHERE id >= 100; SELECT 1 AS a; ", 11, 1, $strict_on); mysqli_close($link); var_dump(mysqli_next_result($link)); print "done!"; ?> --EXPECTF-- Warning: mysqli_next_result(): Couldn't fetch mysqli in %s on line %d NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_num_fields.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_num_fields.phpt +++ php-src/ext/mysqli/tests/mysqli_num_fields.phpt --TEST-- mysqli_num_fields() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_num_fields())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_num_fields($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); function func_test_mysqli_num_fields($link, $query, $expected, $offset, $test_free = false) { if (!($res = mysqli_query($link, $query))) { printf("[%03d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link)); return; } if ($expected !== ($tmp = mysqli_num_fields($res))) printf("[%03d] Expecting %s/%d, got %s/%d\n", $offset + 1, gettype($expected), $expected, gettype($tmp), $tmp); mysqli_free_result($res); if ($test_free && (NULL !== ($tmp = mysqli_num_fields($res)))) printf("[%03d] Expecting NULL, got %s/%s\n", $offset + 2, gettype($tmp), $tmp); } func_test_mysqli_num_fields($link, "SELECT 1 AS a", 1, 5); func_test_mysqli_num_fields($link, "SELECT id, label FROM test", 2, 10); func_test_mysqli_num_fields($link, "SELECT 1 AS a, NULL AS b, 'foo' AS c", 3, 15); func_test_mysqli_num_fields($link, "SELECT id FROM test", 1, 20, true); mysqli_close($link); print "done!"; ?> --EXPECTF-- Warning: mysqli_num_fields(): Couldn't fetch mysqli_result in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_num_rows.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_num_rows.phpt +++ php-src/ext/mysqli/tests/mysqli_num_rows.phpt --TEST-- mysqli_num_rows() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_num_rows())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_num_rows($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); function func_test_mysqli_num_rows($link, $query, $expected, $offset, $test_free = false) { if (!$res = mysqli_query($link, $query, MYSQLI_STORE_RESULT)) { printf("[%03d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link)); return; } if ($expected !== ($tmp = mysqli_num_rows($res))) printf("[%03d] Expecting %s/%d, got %s/%d\n", $offset + 1, gettype($expected), $expected, gettype($tmp), $tmp); mysqli_free_result($res); if ($test_free && (NULL !== ($tmp = mysqli_num_rows($res)))) printf("[%03d] Expecting NULL, got %s/%s\n", $offset + 2, gettype($tmp), $tmp); } func_test_mysqli_num_rows($link, "SELECT 1 AS a", 1, 5); func_test_mysqli_num_rows($link, "SHOW VARIABLES LIKE '%nixnutz%'", 0, 10); func_test_mysqli_num_rows($link, "INSERT INTO test(id, label) VALUES (100, 'z')", NULL, 15); func_test_mysqli_num_rows($link, "SELECT id FROM test LIMIT 2", 2, 20, true); if ($res = mysqli_query($link, 'SELECT COUNT(id) AS num FROM test')) { $row = mysqli_fetch_assoc($res); mysqli_free_result($res); func_test_mysqli_num_rows($link, "SELECT id, label FROM test", (int)$row['num'], 25); } else { printf("[030] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } print "run_tests.php don't fool me with your 'ungreedy' expression '.+?'!\n"; if ($res = mysqli_query($link, 'SELECT id FROM test', MYSQLI_USE_RESULT)) { $row = mysqli_fetch_row($res); if (0 !== ($tmp = mysqli_num_rows($res))) printf("[031] Expecting int/0, got %s/%d\n", gettype($tmp), $tmp); mysqli_free_result($res); } else { printf("[032] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } mysqli_close($link); print "done!"; ?> --EXPECTF-- Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in %s on line %d Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, boolean given in %s on line %d Warning: mysqli_num_rows(): Couldn't fetch mysqli_result in %s on line %d run_tests.php don't fool me with your 'ungreedy' expression '.+?'! Warning: mysqli_num_rows(): Function cannot be used with MYSQL_USE_RESULT in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_options.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_options.phpt +++ php-src/ext/mysqli/tests/mysqli_options.phpt --TEST-- mysqli_options() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $valid_options = array( MYSQLI_READ_DEFAULT_GROUP, MYSQLI_READ_DEFAULT_FILE, MYSQLI_OPT_CONNECT_TIMEOUT, MYSQLI_OPT_LOCAL_INFILE, MYSQLI_INIT_COMMAND, MYSQLI_READ_DEFAULT_GROUP, MYSQLI_READ_DEFAULT_FILE, MYSQLI_OPT_CONNECT_TIMEOUT, MYSQLI_OPT_LOCAL_INFILE, MYSQLI_INIT_COMMAND, MYSQLI_SET_CHARSET_NAME); if ($IS_MYSQLND && defined('MYSQLI_OPT_INT_AND_YEARS_AS_INT')) $valid_options[] = constant('MYSQLI_OPT_INT_AND_YEARS_AS_INT'); if (defined('MYSQLI_OPT_NUMERIC_AND_DATETIME_AS_UNICODE')) $valid_options[] = constant('MYSQLI_OPT_NUMERIC_AND_DATETIME_AS_UNICODE'); $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_options())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_options($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); $link = mysqli_init(); if (!is_null($tmp = @mysqli_options($link, MYSQLI_OPT_CONNECT_TIMEOUT))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_options($link, "s", 'extra_my.cnf'))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_options($link, MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT=0', 'foo'))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); // print "run_tests.php don't fool me with your 'ungreedy' expression '.+?'!\n"; var_dump("MYSQLI_READ_DEFAULT_GROUP", mysqli_options($link, MYSQLI_READ_DEFAULT_GROUP, 'extra_my.cnf')); var_dump("MYSQLI_READ_DEFAULT_FILE", mysqli_options($link, MYSQLI_READ_DEFAULT_FILE, 'extra_my.cnf')); var_dump("MYSQLI_OPT_CONNECT_TIMEOUT", mysqli_options($link, MYSQLI_OPT_CONNECT_TIMEOUT, 10)); var_dump("MYSQLI_OPT_LOCAL_INFILE", mysqli_options($link, MYSQLI_OPT_LOCAL_INFILE, 1)); var_dump("MYSQLI_INIT_COMMAND", mysqli_options($link, MYSQLI_INIT_COMMAND, array('SET AUTOCOMMIT=0', 'SET AUTOCOMMIT=1'))); var_dump("MYSQLI_READ_DEFAULT_GROUP", mysqli_options($link, MYSQLI_READ_DEFAULT_GROUP, 'extra_my.cnf')); var_dump("MYSQLI_READ_DEFAULT_FILE", mysqli_options($link, MYSQLI_READ_DEFAULT_FILE, 'extra_my.cnf')); var_dump("MYSQLI_OPT_CONNECT_TIMEOUT", mysqli_options($link, MYSQLI_OPT_CONNECT_TIMEOUT, 10)); var_dump("MYSQLI_OPT_LOCAL_INFILE", mysqli_options($link, MYSQLI_OPT_LOCAL_INFILE, 1)); var_dump("MYSQLI_INIT_COMMAND", mysqli_options($link, MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT=0')); var_dump("MYSQLI_CLIENT_SSL", mysqli_options($link, MYSQLI_CLIENT_SSL, 'not an mysqli_option')); if ($IS_MYSQLND && defined('MYSQLI_OPT_INT_AND_YEARS_AS_INT') && !($tmp = mysqli_options($link, constant('MYSQLI_OPT_INT_AND_YEARS_AS_INT'), true))) printf("[006] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp); if (defined('MYSQLI_OPT_NUMERIC_AND_DATETIME_AS_UNICODE') && !($tmp = mysqli_options($link, constant('MYSQLI_OPT_NUMERIC_AND_DATETIME_AS_UNICODE'), true))) printf("[006] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp); for ($flag = -10000; $flag < 10000; $flag++) { if (in_array($flag, $valid_options)) continue; if (FALSE !== ($tmp = mysqli_options($link, $flag, 'definetely not an mysqli_option'))) { var_dump("SOME_FLAG", $flag, $tmp); } } mysqli_close($link); echo "Link closed"; var_dump("MYSQLI_INIT_COMMAND", mysqli_options($link, MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT=1')); var_dump("SOME_RANDOM_FLAG", mysqli_options($link, $flag, 'definetly not an mysqli_option')); print "done!"; ?> --EXPECTF-- %s(25) "MYSQLI_READ_DEFAULT_GROUP" bool(true) %s(24) "MYSQLI_READ_DEFAULT_FILE" bool(true) %s(26) "MYSQLI_OPT_CONNECT_TIMEOUT" bool(true) %s(23) "MYSQLI_OPT_LOCAL_INFILE" bool(true) %s(19) "MYSQLI_INIT_COMMAND" bool(true) %s(25) "MYSQLI_READ_DEFAULT_GROUP" bool(true) %s(24) "MYSQLI_READ_DEFAULT_FILE" bool(true) %s(26) "MYSQLI_OPT_CONNECT_TIMEOUT" bool(true) %s(23) "MYSQLI_OPT_LOCAL_INFILE" bool(true) %s(19) "MYSQLI_INIT_COMMAND" bool(true) %s(17) "MYSQLI_CLIENT_SSL" bool(false) Link closed Warning: mysqli_options(): Couldn't fetch mysqli in %s line %d %s(19) "MYSQLI_INIT_COMMAND" NULL Warning: mysqli_options(): Couldn't fetch mysqli in %s line %d %s(16) "SOME_RANDOM_FLAG" NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_options_init_command.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_options_init_command.phpt +++ php-src/ext/mysqli/tests/mysqli_options_init_command.phpt --TEST-- mysqli_options() --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); die("skip - STUB - TODO - this is a stub to remind me that we should also actually test the options"); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php /* see mysqli.c for details */ include "connect.inc"; print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_pconnect.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_pconnect.phpt +++ php-src/ext/mysqli/tests/mysqli_pconnect.phpt --TEST-- mysqli_pconnect() --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); if (!stristr(mysqli_get_client_info(), 'mysqlnd')) die("skip: only available in mysqlnd"); ?> --FILE-- <?php include "connect.inc"; $host = 'p:' . $host; if (!$link = mysqli_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); mysqli_close($link); $num = 20; $connections = array(); for ($i = 0; $i < $num; $i++) { if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[003] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); $connections[] = $link; } while (count($connections)) { do { $index = mt_rand(0, $num); } while (!isset($connections[$index])); mysqli_close($connections[$index]); unset($connections[$index]); } $connections = array(); $num = 20; for ($i = 0; $i < $num; $i++) { if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[004] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); $connections[] = $link; } $left = $num; while (count($connections) && $left > 0) { do { $index = mt_rand(0, $num); } while (!isset($connections[$index]) && $left > 0); if (mt_rand(0, 1) > 0) { $left--; mysqli_close($connections[$index]); unset($connections[$index]); } else { $left--; if (!$connections[$index] = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[004] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); } flush(); } while (count($connections)) { do { $index = mt_rand(0, $num); } while (!isset($connections[$index])); mysqli_close($connections[$index]); unset($connections[$index]); } print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_phpinfo.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_phpinfo.phpt +++ php-src/ext/mysqli/tests/mysqli_phpinfo.phpt --TEST-- phpinfo() mysqli section --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include("connect.inc"); @ob_clean(); ob_start(); phpinfo(); $phpinfo = ob_get_contents(); ob_end_clean(); /* all versions should at least dump this minimum information */ if (!stristr($phpinfo, "mysqli support")) printf("[001] ext/mysqli should have exposed itself.\n"); if (!stristr($phpinfo, "client api library version")) printf("[002] ext/mysqli should have exposed the library version.\n"); if (!stristr($phpinfo, "mysqli.default_host")) printf("[003] php.ini setting mysqli.default_host not shown.\n"); if (!stristr($phpinfo, "mysqli.default_port")) printf("[004] php.ini setting mysqli.default_port not shown.\n"); if (!stristr($phpinfo, "mysqli.default_pw")) printf("[005] php.ini setting mysqli.default_pw not shown.\n"); if (!stristr($phpinfo, "mysqli.default_socket")) printf("[006] php.ini setting mysqli.default_socket not shown.\n"); if (!stristr($phpinfo, "mysqli.default_user")) printf("[007] php.ini setting mysqli.default_user not shown.\n"); if (!stristr($phpinfo, "mysqli.max_links")) printf("[008] php.ini setting mysqli.max_links not shown.\n"); if (!stristr($phpinfo, "mysqli.reconnect")) printf("[009] php.ini setting mysqli.reconnect not shown.\n"); if ($IS_MYSQLND) { $expected = array( 'client statistics', 'bytes_sent', 'bytes_received', 'packets_sent', 'packets_received', 'protocol_overhead_in', 'protocol_overhead_out', 'result_set_queries', 'non_result_set_queries', 'no_index_used', 'bad_index_used', 'buffered_sets', 'unbuffered_sets', 'ps_buffered_sets', 'ps_unbuffered_sets', 'flushed_normal_sets', 'flushed_ps_sets', 'rows_fetched_from_server', 'rows_fetched_from_client', 'rows_skipped', 'copy_on_write_saved', 'copy_on_write_performed', 'command_buffer_too_small', 'connect_success', 'connect_failure', 'connection_reused', 'explicit_close', 'implicit_close', 'disconnect_close', 'in_middle_of_command_close', 'explicit_free_result', 'implicit_free_result', 'explicit_stmt_close', 'implicit_stmt_close', 'put_hits', 'put_misses', 'get_hits', 'get_misses', 'size', 'free_items', 'references', 'mysqli.cache_size', 'mysql.allow_local_infile' ); foreach ($expected as $k => $entry) if (!stristr($phpinfo, $entry)) printf("[010] Could not find entry for '%s'\n", $entry); } print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_ping.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_ping.phpt +++ php-src/ext/mysqli/tests/mysqli_ping.phpt --TEST-- mysqli_ping() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_ping())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!is_null($tmp = @mysqli_ping($link, $link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); var_dump(mysqli_ping($link)); // provoke an error to check if mysqli_ping resets it $res = mysqli_query($link, 'SELECT * FROM unknown_table'); if (!($errno = mysqli_errno($link))) printf("[003] Statement should have caused an error\n"); var_dump(mysqli_ping($link)); if ($errno === mysqli_errno($link)) printf("[004] Error codes should have been reset\n"); mysqli_close($link); if (!is_null($tmp = mysqli_ping($link))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- bool(true) bool(true) Warning: mysqli_ping(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_prepare.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_prepare.phpt +++ php-src/ext/mysqli/tests/mysqli_prepare.phpt --TEST-- mysqli_prepare() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_prepare())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_prepare($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (false !== ($tmp = @mysqli_prepare($link, false))) printf("[003] Expecting boolean/false, got %s\n", gettype($tmp)); if (!$res = mysqli_query($link, "SELECT id, label FROM test", MYSQLI_USE_RESULT)) printf("[004] [%d] %s, next test will fail\n", mysqli_errno($link), mysqli_error($link)); if (false !== ($tmp = mysqli_prepare($link, 'SELECT id FROM test WHERE id > ?'))) printf("[005] Expecting boolean/false, got %s, [%d] %s\n", gettype($tmp), mysqli_errno($link), mysqli_error($link)); mysqli_free_result($res); if (!is_object(($stmt = mysqli_prepare($link, 'SELECT id FROM test'))) || !mysqli_stmt_execute($stmt)) printf("[006][%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_stmt_close($stmt); if (!mysqli_query($link, "DROP TABLE IF EXISTS test2")) printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_object(($stmt = mysqli_prepare($link, 'CREATE TABLE test2(id INT) ENGINE =' . $engine))) || !mysqli_stmt_execute($stmt)) printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_stmt_close($stmt); if (!is_object(($stmt = mysqli_prepare($link, 'INSERT INTO test2(id) VALUES(?)')))) printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $id = 1; if (!mysqli_bind_param($stmt, 'i', $id) || !mysqli_stmt_execute($stmt)) printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_stmt_close($stmt); if (!is_object(($stmt = mysqli_prepare($link, 'REPLACE INTO test2(id) VALUES (?)')))) printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $id = 2; if (!mysqli_bind_param($stmt, 'i', $id) || !mysqli_stmt_execute($stmt)) printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_stmt_close($stmt); if (!is_object(($stmt = mysqli_prepare($link, 'UPDATE test2 SET id = ? WHERE id = ?')))) printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $id = 3; $where = 2; if (!mysqli_bind_param($stmt, 'ii', $id, $where) || !mysqli_stmt_execute($stmt)) printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_stmt_close($stmt); if (!is_object(($stmt = mysqli_prepare($link, 'DELETE FROM test2 WHERE id = ?')))) printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $where = 3; if (!mysqli_bind_param($stmt, 'i', $where) || !mysqli_stmt_execute($stmt)) printf("[016] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_stmt_close($stmt); if (!is_object(($stmt = mysqli_prepare($link, 'SET @testvar = ?')))) printf("[017] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $testvar = 'testvar'; if (!mysqli_bind_param($stmt, 's', $testvar) || !mysqli_stmt_execute($stmt)) printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_stmt_close($stmt); if (!is_object(($stmt = mysqli_prepare($link, 'DO GET_LOCK("testlock", 1)')))) printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_stmt_close($stmt); if (!is_object(($stmt = mysqli_prepare($link, 'SELECT id, @testvar FROM test2')))) printf("[020] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $id = $testvar = null; if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_bind_result($stmt, $id, $testvar)) printf("[021] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); while (mysqli_stmt_fetch($stmt)) { if (('testvar' !== $testvar) || (1 !== $id)) printf("[022] Expecting 'testvar'/1, got %s/%s. [%d] %s\n", $testvar, $id, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); } var_dump(mysqli_stmt_prepare($stmt, 'SELECT 1; SELECT 2')); mysqli_stmt_close($stmt); if (!is_null($tmp = @mysqli_stmt_prepare($link, 'SELECT id FROM test', 'foo'))) printf("[023] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); if (!is_null($tmp = @mysqli_stmt_prepare($link, 'SELECT id FROM test'))) printf("[024] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- bool(false) done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_prepare_no_object.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_prepare_no_object.phpt +++ php-src/ext/mysqli/tests/mysqli_prepare_no_object.phpt --TEST-- mysqli_prepare() - no object on failure --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; require('table.inc'); if (false !== ($tmp = mysqli_prepare($link, false))) printf("[001] Expecting boolean/false, got %s/%s\n", gettype($tmp), (is_object($tmp) ? var_dump($tmp, true) : $tmp)); printf("a) [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (false !== ($tmp = mysqli_prepare($link, ''))) printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), (is_object($tmp) ? var_dump($tmp, true) : $tmp)); printf("b) [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_close($link); if (!$mysqli = new mysqli($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); if (false !== ($tmp = $mysqli->prepare(false))) printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), (is_object($tmp) ? var_dump($tmp, true) : $tmp)); printf("c) [%d] %s\n", $mysqli->errno, $mysqli->error); if (false !== ($tmp = $mysqli->prepare(''))) printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), (is_object($tmp) ? var_dump($tmp, true) : $tmp)); printf("c) [%d] %s\n", $mysqli->errno, $mysqli->error); print "done!"; ?> --EXPECTF-- a) [1065] Query was empty b) [1065] Query was empty c) [1065] Query was empty c) [1065] Query was empty done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_query.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_query.phpt +++ php-src/ext/mysqli/tests/mysqli_query.phpt --TEST-- mysqli_query() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_query())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_query($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (false !== ($tmp = @mysqli_query($link, ''))) printf("[002a] Expecting boolean/false got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_query($link, "SELECT 1 AS a", MYSQLI_USE_RESULT, "foo"))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysqli_query($link, 'THIS IS NOT SQL'))) printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysqli_query($link, 'SELECT "this is sql but with backslash g"\g'))) printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if ((0 === mysqli_errno($link)) || ('' == mysqli_error($link))) printf("[006] mysqli_errno()/mysqli_error should return some error\n"); if (!$res = mysqli_query($link, 'SELECT "this is sql but with semicolon" AS valid ; ')) printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump(mysqli_fetch_assoc($res)); mysqli_free_result($res); if (!$res = mysqli_query($link, 'SELECT "a" AS ""')) printf("[007a] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump($tmp = mysqli_fetch_assoc($res)); var_dump($tmp[""]); mysqli_free_result($res); if (false !== ($res = mysqli_query($link, 'SELECT "this is sql but with semicolon" AS valid ; SHOW VARIABLES'))) printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (mysqli_get_server_version($link) > 50000) { // let's try to play with stored procedures mysqli_query($link, 'DROP PROCEDURE IF EXISTS p'); if (mysqli_query($link, 'CREATE PROCEDURE p(OUT ver_param VARCHAR(25)) BEGIN SELECT VERSION() INTO ver_param; END;')) { $res = mysqli_query($link, 'CALL p(@version)'); $res = mysqli_query($link, 'SELECT @version AS p_version'); $tmp = mysqli_fetch_assoc($res); if (!is_array($tmp) || empty($tmp) || !isset($tmp['p_version']) || ('' == $tmp['p_version'])) { printf("[008a] Expecting array [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump($tmp); } mysqli_free_result($res); } else { printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } mysqli_query($link, 'DROP FUNCTION IF EXISTS f'); if (mysqli_query($link, 'CREATE FUNCTION f( ver_param VARCHAR(25)) RETURNS VARCHAR(25) DETERMINISTIC RETURN ver_param;')) { $res = mysqli_query($link, 'SELECT f(VERSION()) AS f_version'); $tmp = mysqli_fetch_assoc($res); if (!is_array($tmp) || empty($tmp) || !isset($tmp['f_version']) || ('' == $tmp['f_version'])) { printf("[009a] Expecting array [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump($tmp); } mysqli_free_result($res); } else { printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } } if (!is_object($res = mysqli_query($link, "SELECT id FROM test ORDER BY id", MYSQLI_USE_RESULT))) printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_free_result($res); if (!is_object($res = mysqli_query($link, "SELECT id FROM test ORDER BY id", MYSQLI_STORE_RESULT))) printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_free_result($res); $valid = array(MYSQLI_USE_RESULT, MYSQLI_STORE_RESULT); do { $mode = mt_rand(-1000, 1000); } while (in_array($mode, $valid)); if (false !== ($res = @mysqli_query($link, "SELECT id FROM test ORDER BY id", $mode))) printf("[013] Invalid mode should return false got %s/%s, [%d] %s\n", gettype($res), (is_object($res)) ? 'object' : $res, mysqli_errno($link), mysqli_error($link)); mysqli_close($link); if (NULL !== ($tmp = mysqli_query($link, "SELECT id FROM test"))) printf("[011] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- array(1) { ["valid"]=> string(30) "this is sql but with semicolon" } array(1) { [""]=> string(1) "a" } string(1) "a" Warning: mysqli_query(): Couldn't fetch mysqli in %s on line %d done! --UEXPECTF-- array(1) { [u"valid"]=> unicode(30) "this is sql but with semicolon" } array(1) { [u""]=> unicode(1) "a" } unicode(1) "a" Warning: mysqli_query(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_query_unicode.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_query_unicode.phpt +++ php-src/ext/mysqli/tests/mysqli_query_unicode.phpt --TEST-- mysqli_query() - unicode (cyrillic) --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('connect.inc'); require_once('table.inc'); if (!$res = mysqli_query($link, "SHOW CHARACTER SET LIKE 'utf8'")) die("skip UTF8 chatset seems not available"); mysqli_free_result($res); mysqli_close($link); ?> --FILE-- <?php include_once("connect.inc"); $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_query())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_query($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require_once('table.inc'); if (TRUE !== ($tmp = @mysqli_query($link, "set names utf8"))) printf("[002.5] Expecting TRUE, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_query($link, "SELECT 1 AS колона", MYSQLI_USE_RESULT, "foo"))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysqli_query($link, 'Ñова не е еÑкÑел'))) printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysqli_query($link, 'SELECT "Ñова е еÑкÑел, но ÑÑÑ Ð¾Ð±ÑаÑна наклонена и g"\g'))) printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if ((0 === mysqli_errno($link)) || ('' == mysqli_error($link))) printf("[006] mysqli_errno()/mysqli_error should return some error\n"); if (!$res = mysqli_query($link, 'SELECT "Ñова еÑкÑел, но Ñ ÑоÑка и запеÑаÑ" AS пÑавилен ; ')) printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump(mysqli_fetch_assoc($res)); mysqli_free_result($res); if (false !== ($res = mysqli_query($link, 'SELECT "Ñова еÑкÑел, но Ñ ÑоÑка и запеÑаÑ" AS пÑавилен ; SHOW VARIABLES'))) printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (mysqli_get_server_version($link) > 50000) { // let's try to play with stored procedures mysqli_query($link, 'DROP PROCEDURE IF EXISTS пÑоÑедÑÑка'); if (mysqli_query($link, 'CREATE PROCEDURE пÑоÑедÑÑка(OUT веÑÑÐ¸Ñ VARCHAR(25)) BEGIN SELECT VERSION() INTO веÑÑиÑ; END;')) { $res = mysqli_query($link, 'CALL пÑоÑедÑÑка(@version)'); $res = mysqli_query($link, 'SELECT @version AS п_веÑÑиÑ'); $tmp = mysqli_fetch_assoc($res); if (!is_array($tmp) || empty($tmp) || !isset($tmp['п_веÑÑиÑ']) || ('' == $tmp['п_веÑÑиÑ'])) { printf("[008a] Expecting array [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump($tmp); } mysqli_free_result($res); } else { printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } mysqli_query($link, 'DROP FUNCTION IF EXISTS ÑÑнкÑийка'); if (mysqli_query($link, 'CREATE FUNCTION ÑÑнкÑийка( паÑамеÑÑÑ_веÑÑÐ¸Ñ VARCHAR(25)) RETURNS VARCHAR(25) DETERMINISTIC RETURN паÑамеÑÑÑ_веÑÑиÑ;')) { $res = mysqli_query($link, 'SELECT ÑÑнкÑийка(VERSION()) AS Ñ_веÑÑиÑ'); $tmp = mysqli_fetch_assoc($res); if (!is_array($tmp) || empty($tmp) || !isset($tmp['Ñ_веÑÑиÑ']) || ('' == $tmp['Ñ_веÑÑиÑ'])) { printf("[009a] Expecting array [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump($tmp); } mysqli_free_result($res); } else { printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } } /* Trying to test what Ramil suggests in http://bugs.mysql.com/bug.php?id=29576 However, this won't work, because we're lacking MYSQLI_SET_CHARSET_NAME. if (ini_get("unicode.semantics")) { if (mysqli_get_server_version() > 50002) { @mysqli_query($link, "DROP USER IF EXISTS 'ÑеÑÑ'@'%'"); if (TRUE !== mysqli_query($link, "CREATE USER 'ÑеÑÑ'@'%'")) { var_dump(mysqli_error($link); } } if (TRUE !== mysqli_query($link, "GRANT SELECT ON $db.* TO 'ÑеÑÑ'@'%' IDENTIFIED BY 'паÑола'")) { var_dump(mysqli_error($link); } else { $link2 = mysqli_init(); if (!(mysqli_real_connect($link2, $host, "ÑеÑÑ", 'паÑола', $db, $port, $socket))) { printf("[011] Cannot connect to the server using host=%s, user=%s, passwd=паÑола, dbname=%s, port=%s, socket=%s, [%d] %s\n", $host, "ÑеÑÑ", $db, $port, $socket, mysqli_connect_errno(), mysqli_connect_error()); } mysqli_close($link2); if (mysqli_get_server_version() > 50002) { if (!mysqli_query($link, "DROP USER 'ÑеÑÑ'@'%'")) printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } else { printf("[015] Cannot create user or grant privileges, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } } } } */ mysqli_close($link); if (NULL !== ($tmp = mysqli_query($link, "SELECT id FROM test"))) printf("[014] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- array(1) { ["пÑавилен"]=> string(59) "Ñова еÑкÑел, но Ñ ÑоÑка и запеÑаÑ" } Warning: mysqli_query(): Couldn't fetch mysqli in %s on line %d done! --UEXPECTF-- array(1) { [u"пÑавилен"]=> unicode(33) "Ñова еÑкÑел, но Ñ ÑоÑка и запеÑаÑ" } Warning: mysqli_query(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_real_escape_string.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_real_escape_string.phpt +++ php-src/ext/mysqli/tests/mysqli_real_escape_string.phpt --TEST-- mysqli_real_escape_string() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (NULL !== ($tmp = @mysqli_real_escape_string())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_real_escape_string($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (NULL !== ($tmp =@mysqli_real_escape_string($link, "foo", "foo"))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if ('\\\\' !== ($tmp = mysqli_real_escape_string($link, '\\'))) printf("[004] Expecting \\\\, got %s\n", $tmp); if ('\"' !== ($tmp = mysqli_real_escape_string($link, '"'))) printf("[005] Expecting \", got %s\n", $tmp); if ("\'" !== ($tmp = mysqli_real_escape_string($link, "'"))) printf("[006] Expecting ', got %s\n", $tmp); if ("\\n" !== ($tmp = mysqli_real_escape_string($link, "\n"))) printf("[007] Expecting \\n, got %s\n", $tmp); if ("\\r" !== ($tmp = mysqli_real_escape_string($link, "\r"))) printf("[008] Expecting \\r, got %s\n", $tmp); if ("foo\\0bar" !== ($tmp = mysqli_real_escape_string($link, "foo" . chr(0) . "bar"))) printf("[009] Expecting %s, got %s\n", "foo\\0bar", $tmp); mysqli_close($link); if (NULL !== ($tmp = mysqli_real_escape_string($link, 'foo'))) printf("[010] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); /* Make sure that the function alias exists */ if (NULL !== ($tmp = @mysqli_escape_string())) printf("[011] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_real_escape_string(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_real_escape_string_unicode.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_real_escape_string_unicode.phpt +++ php-src/ext/mysqli/tests/mysqli_real_escape_string_unicode.phpt --TEST-- mysqli_real_escape_string() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (NULL !== ($tmp = @mysqli_real_escape_string())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_real_escape_string($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (NULL !== ($tmp =@mysqli_real_escape_string($link, "ÑÑÑ", "баÑ"))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if ('ÑÑ\\\\баÑ' !== ($tmp = mysqli_real_escape_string($link, 'ÑÑ\\баÑ'))) printf("[004] Expecting ÑÑ\\\\баÑ, got %s\n", $tmp); if ('баÑ\"ÑÑÑ' !== ($tmp = mysqli_real_escape_string($link, 'баÑ"ÑÑÑ'))) printf("[005] Expecting баÑ\"ÑÑÑ, got %s\n", $tmp); if ("лала\'лали" !== ($tmp = mysqli_real_escape_string($link, "лала'лали"))) printf("[006] Expecting лала'лали, got %s\n", $tmp); if ("абÑа\\nкадабÑа" !== ($tmp = mysqli_real_escape_string($link, "абÑа\nкадабÑа"))) printf("[007] Expecting абÑа\\nкадабÑа, got %s\n", $tmp); if ("манда\\rин" !== ($tmp = mysqli_real_escape_string($link, "манда\rин"))) printf("[008] Expecting \\r, got %s\n", $tmp); if ("Ð¸Ñ Ñ\\0Ð°Ñ Ñ" !== ($tmp = mysqli_real_escape_string($link, "Ð¸Ñ Ñ" . chr(0) . "Ð°Ñ Ñ"))) printf("[009] Expecting %s, got %s\n", "Ð¸Ñ Ñ\\0Ð°Ñ Ñ", $tmp); if (($exp='абÑа\\\\ка\"да\\'."'".'бÑа\ZÑим\\nÑала\\rби\\0м') !== ($tmp = mysqli_real_escape_string($link, "абÑа\\ка\"да'бÑа\032Ñим\nÑала\rби" . chr(0) . "м"))) { printf("[010] Expecting %s, got %s\n", $exp, $tmp, var_dump($exp, $tmp)); } if ('å¯\\\\é å§' !== ($tmp = mysqli_real_escape_string($link, 'å¯\\é å§'))) printf("[011] Expecting å¯\\\\é å§, got %s\n", $tmp); if ('é å§\"å°é¢å¤§å' !== ($tmp = mysqli_real_escape_string($link, 'é å§"å°é¢å¤§å'))) printf("[012] Expecting é å§\"å°é¢å¤§å, got %s\n", $tmp); if ("ææ\'西é å¾" !== ($tmp = mysqli_real_escape_string($link, "ææ'西é å¾"))) printf("[013] Expecting ææ'西é å¾, got %s\n", $tmp); if ("é¿åæ\\nè½»" !== ($tmp = mysqli_real_escape_string($link, "é¿åæ\nè½»"))) printf("[014] Expecting é¿åæ\\nè½», got %s\n", $tmp); if ("å¼ æå®\\rå¨" !== ($tmp = mysqli_real_escape_string($link, "å¼ æå®\rå¨"))) printf("[015] Expecting å¼ æå®\\rå¨, got %s\n", $tmp); if ("ç«ºå¯æ¡¢\\0空è°å¨" !== ($tmp = mysqli_real_escape_string($link, "ç«ºå¯æ¡¢" . chr(0) . "空è°å¨"))) printf("[016] Expecting %s, got %s\n", "ç«ºå¯æ¡¢\\0空è°å¨", $tmp); if (($exp='é¿åæ\\\\å\"达丰\\'."'".'乳罩\Zè¾\\nè¨æ\\ræ¯\\0ç±³') !== ($tmp = mysqli_real_escape_string($link, "é¿åæ\\å\"达丰'乳罩\032è¾\nè¨æ\ræ¯" . chr(0) . "ç±³"))) { printf("[017] Expecting %s, got %s\n", $exp, $tmp, var_dump($exp, $tmp)); } mysqli_close($link); if (NULL !== ($tmp = mysqli_real_escape_string($link, 'foo'))) printf("[018] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_real_escape_string(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_real_query.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_real_query.phpt +++ php-src/ext/mysqli/tests/mysqli_real_query.phpt --TEST-- mysqli_real_query() --SKIPIF-- <?php require_once('skipif.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_real_query())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_real_query($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (NULL !== ($tmp = @mysqli_real_query($link, "SELECT 1 AS a", MYSQLI_USE_RESULT, "foo"))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysqli_real_query($link, 'THIS IS NOT SQL'))) printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysqli_real_query($link, 'SELECT "this is sql but with backslash g"\g'))) printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if ((0 === mysqli_errno($link)) || ('' == mysqli_error($link))) printf("[006] mysqli_errno()/mysqli_error should return some error\n"); if (!mysqli_real_query($link, 'SELECT "this is sql but with semicolon" AS valid ; ')) printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_object($res = mysqli_use_result($link))) printf("[008] Expecting reseult object, got %s/%s [%d] %s\n", gettype($res), $res, mysqli_errno($link), mysqli_error($link)); var_dump(mysqli_fetch_assoc($res)); mysqli_free_result($res); if (false !== ($res = mysqli_real_query($link, 'SELECT "this is sql but with semicolon" AS valid ; SHOW VARIABLES'))) printf("[008] Expecting boolean/false, got %s/%s, [%d] %s\n", gettype($res), $res, mysqli_errno($link), mysqli_error($link)); if (mysqli_get_server_version($link) > 50000) { // let's try to play with stored procedures mysqli_real_query($link, 'DROP PROCEDURE IF EXISTS p'); if (mysqli_real_query($link, 'CREATE PROCEDURE p(OUT ver_param VARCHAR(25)) BEGIN SELECT VERSION() INTO ver_param; END;')) { mysqli_real_query($link, 'CALL p(@version)'); mysqli_real_query($link, 'SELECT @version AS p_version'); $res = mysqli_store_result($link); $tmp = mysqli_fetch_assoc($res); if (!is_array($tmp) || empty($tmp) || !isset($tmp['p_version']) || ('' == $tmp['p_version'])) { printf("[008a] Expecting array [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump($tmp); } mysqli_free_result($res); } else { printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } mysqli_real_query($link, 'DROP FUNCTION IF EXISTS f'); if (mysqli_real_query($link, 'CREATE FUNCTION f( ver_param VARCHAR(25)) RETURNS VARCHAR(25) DETERMINISTIC RETURN ver_param;')) { mysqli_real_query($link, 'SELECT f(VERSION()) AS f_version'); $res = mysqli_store_result($link); $tmp = mysqli_fetch_assoc($res); if (!is_array($tmp) || empty($tmp) || !isset($tmp['f_version']) || ('' == $tmp['f_version'])) { printf("[009a] Expecting array [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump($tmp); } mysqli_free_result($res); } else { printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } } mysqli_close($link); if (NULL !== ($tmp = mysqli_real_query($link, "SELECT id FROM test"))) printf("[011] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- array(1) { ["valid"]=> string(30) "this is sql but with semicolon" } Warning: mysqli_real_query(): Couldn't fetch mysqli in %s on line %d done! --UEXPECTF-- array(1) { [u"valid"]=> unicode(30) "this is sql but with semicolon" } Warning: mysqli_real_query(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_report.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_report.phpt +++ php-src/ext/mysqli/tests/mysqli_report.phpt --TEST-- mysqli_report() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (NULL !== ($tmp = @mysqli_report())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = mysqli_report(-1))) printf("[002] Expecting boolean/true even for invalid flags, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_ERROR))) printf("[003] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_STRICT))) printf("[004] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_INDEX))) printf("[005] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_ALL))) printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_OFF))) printf("[008] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); /* Internal macro MYSQL_REPORT_ERROR */ mysqli_report(MYSQLI_REPORT_ERROR); mysqli_multi_query($link, "BAR; FOO;"); mysqli_query($link, "FOO"); /* This might work if you accept anonymous users in your setup */ mysqli_change_user($link, "0123456789-10-456789-20-456789-30-456789-40-456789-50-456789-60-456789-70-456789-80-456789-90-456789", "password", $db); mysqli_kill($link, -1); // mysqli_ping() cannot be tested, because one would need to cause an error inside the C function to test it mysqli_prepare($link, "FOO"); mysqli_real_query($link, "FOO"); if (@mysqli_select_db($link, "Oh lord, let this be an unknown database name")) printf("[009] select_db should have failed\n"); // mysqli_store_result() and mysqli_use_result() cannot be tested, because one would need to cause an error inside the C function to test it // Check that none of the above would have caused any error messages if MYSQL_REPORT_ERROR would // not have been set. If that would be the case, the test would be broken. mysqli_report(MYSQLI_REPORT_OFF); mysqli_multi_query($link, "BAR; FOO;"); mysqli_query($link, "FOO"); mysqli_change_user($link, "This might work if you accept anonymous users in your setup", "password", $db); mysqli_kill($link, -1); mysqli_prepare($link, "FOO"); mysqli_real_query($link, "FOO"); mysqli_select_db($link, "Oh lord, let this be an unknown database name"); /* Internal macro MYSQL_REPORT_STMT_ERROR */ mysqli_report(MYSQLI_REPORT_ERROR); $stmt = mysqli_stmt_init($link); mysqli_stmt_prepare($stmt, "FOO"); $stmt = mysqli_stmt_init($link); mysqli_stmt_prepare($stmt, "SELECT id FROM test WHERE id > ?"); $id = 1; mysqli_kill($link, mysqli_thread_id($link)); mysqli_stmt_bind_param($stmt, "i", $id); mysqli_stmt_close($stmt); mysqli_close($link); /* mysqli_stmt_execute() = mysql_stmt_execute cannot be tested from PHP */ if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[008] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); $stmt = mysqli_stmt_init($link); mysqli_stmt_prepare($stmt, "SELECT id FROM test WHERE id > ?"); $id = 1; mysqli_stmt_bind_param($stmt, "i", $id); // mysqli_kill($link, mysqli_thread_id($link)); mysqli_stmt_execute($stmt); mysqli_stmt_close($stmt); mysqli_close($link); /* mysqli_kill() "trick" does not work for any of the following because of an E_COMMANDS_OUT_OF_SYNC */ /* mysqli_stmt_bind_result() = mysql_stmt_bind_result() cannot be tested from PHP */ /* mysqli_stmt_fetch() = mysql_stmt_fetch() cannot be tested from PHP */ /* mysqli_stmt_result_metadata() = mysql_stmt_result_metadata() cannot be tested from PHP */ /* mysqli_stmt_store_result() = mysql_stmt_store_result() cannot be tested from PHP */ // Check mysqli_report(MYSQLI_REPORT_OFF); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[010] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); $stmt = mysqli_stmt_init($link); mysqli_stmt_prepare($stmt, "FOO"); $stmt = mysqli_stmt_init($link); mysqli_stmt_prepare($stmt, "SELECT id FROM test WHERE id > ?"); $id = 1; mysqli_kill($link, mysqli_thread_id($link)); mysqli_stmt_bind_param($stmt, "i", $id); mysqli_stmt_close($stmt); mysqli_close($link); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[011] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); $stmt = mysqli_stmt_init($link); mysqli_stmt_prepare($stmt, "SELECT id FROM test WHERE id > ?"); $id = 1; mysqli_stmt_bind_param($stmt, "i", $id); mysqli_kill($link, mysqli_thread_id($link)); mysqli_stmt_execute($stmt); mysqli_stmt_close($stmt); mysqli_close($link); /* MYSQLI_REPORT_STRICT MYSQLI_REPORT_STRICT ---> php_mysqli_report_error() -> MYSQLI_REPORT_MYSQL_ERROR, MYSQLI_REPORT_STMT_ERROR -> already tested php_mysqli_throw_sql_exception() -> mysqli_real_connect() mysqli_connect() can't be tested: mysqli_query() via mysql_use_result()/mysql_store_result() */ mysqli_report(MYSQLI_REPORT_OFF); mysqli_report(MYSQLI_REPORT_STRICT); try { if ($link = mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket)) printf("[012] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", $host, $user . 'unknown_really', $db, $port, $socket); mysqli_close($link); } catch (mysqli_sql_exception $e) { printf("[013] %s\n", $e->getMessage()); } try { if (!$link = mysqli_init()) printf("[014] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); if ($link = mysqli_real_connect($link, $host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket)) printf("[015] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", $host, $user . 'unknown_really', $db, $port, $socket); mysqli_close($link); } catch (mysqli_sql_exception $e) { printf("[016] %s\n", $e->getMessage()); } /* MYSQLI_REPORT_INDEX ---> mysqli_query() mysqli_stmt_execute() mysqli_prepare() mysqli_real_query() mysqli_store_result() mysqli_use_result() No test, because of to many prerequisites: - Server needs to be started with and --log-slow-queries --log-queries-not-using-indexes - query must cause the warning on all MySQL versions TODO: */ $log_slow_queries = false; $log_queries_not_using_indexes = false; if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[017] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); if (!$res = mysqli_query($link, "SHOW VARIABLES LIKE 'log_slow_queries'")) printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$row = mysqli_fetch_assoc($res)) printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $log_slow_query = ('ON' == $row['Value']); if (mysqli_get_server_version($link) >= 51011) { if (!$res = mysqli_query($link, "SHOW VARIABLES LIKE 'log_queries_not_using_indexes'")) printf("[020] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$row = mysqli_fetch_assoc($res)) printf("[021] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $log_queries_not_using_indexes = ('ON' == $row['Value']); if ($log_slow_queries && $log_queries_not_using_indexes) { for ($i = 100; $i < 20000; $i++) { if (!mysqli_query($link, "INSERT INTO test(id, label) VALUES ($i, 'z')")) printf("[022 - %d] [%d] %s\n", $i - 99, mysqli_errno($link), mysqli_error($link)); } if (!$res = @mysqli_query($link, "SELECT id, label FROM test WHERE id = 1323")) printf("[023] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_free_result($res); mysqli_report(MYSQLI_REPORT_OFF); mysqli_report(MYSQLI_REPORT_INDEX); } } print "done!"; ?> --EXPECTF-- Warning: mysqli_multi_query(): (%d/%d): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'BAR; FOO' at line 1 in %s on line %d Warning: mysqli_query(): (%d/%d): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FOO' at line 1 in %s on line %d Warning: mysqli_change_user(): (%d/%d): Access denied for user '0123456789-10-456789-20-456789-%s'@'%s' (using password: YES) in %s on line %d Warning: mysqli_kill(): processid should have positive value in %s on line %d Warning: mysqli_prepare(): (%d/%d): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FOO' at line 1 in %s on line %d Warning: mysqli_real_query(): (%d/%d): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FOO' at line 1 in %s on line %d Warning: mysqli_kill(): processid should have positive value in %s on line %d Warning: mysqli_stmt_prepare(): (%d/%d): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FOO' at line 1 in %s on line %d [013] Access denied for user '%s'@'%s' (using password: YES) [016] Access denied for user '%s'@'%s' (using password: YES) done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_report_wo_ps.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_report_wo_ps.phpt +++ php-src/ext/mysqli/tests/mysqli_report_wo_ps.phpt --TEST-- mysqli_report() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (NULL !== ($tmp = @mysqli_report())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = mysqli_report(-1))) printf("[002] Expecting boolean/true even for invalid flags, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_ERROR))) printf("[003] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_STRICT))) printf("[004] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_INDEX))) printf("[005] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_ALL))) printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_OFF))) printf("[008] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); /* Internal macro MYSQL_REPORT_ERROR */ mysqli_report(MYSQLI_REPORT_ERROR); mysqli_multi_query($link, "BAR; FOO;"); mysqli_query($link, "FOO"); mysqli_change_user($link, "0123456789-10-456789-20-456789-30-456789-40-456789-50-456789-60-456789-70-456789-80-456789-90-456789", "password", $db); mysqli_kill($link, -1); // mysqli_ping() cannot be tested, because one would need to cause an error inside the C function to test it mysqli_real_query($link, "FOO"); if (@mysqli_select_db($link, "Oh lord, let this be an unknown database name")) printf("[009] select_db should have failed\n"); // mysqli_store_result() and mysqli_use_result() cannot be tested, because one would need to cause an error inside the C function to test it // Check that none of the above would have caused any error messages if MYSQL_REPORT_ERROR would // not have been set. If that would be the case, the test would be broken. mysqli_report(MYSQLI_REPORT_OFF); mysqli_multi_query($link, "BAR; FOO;"); mysqli_query($link, "FOO"); mysqli_change_user($link, "This might work if you accept anonymous users in your setup", "password", $db); mysqli_kill($link, -1); mysqli_real_query($link, "FOO"); mysqli_select_db($link, "Oh lord, let this be an unknown database name"); mysqli_report(MYSQLI_REPORT_OFF); mysqli_report(MYSQLI_REPORT_STRICT); try { if ($link = mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket)) printf("[010] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", $host, $user . 'unknown_really', $db, $port, $socket); mysqli_close($link); } catch (mysqli_sql_exception $e) { printf("[011] %s\n", $e->getMessage()); } try { if (!$link = mysqli_init()) printf("[012] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); if ($link = mysqli_real_connect($link, $host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket)) printf("[013] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", $host, $user . 'unknown_really', $db, $port, $socket); mysqli_close($link); } catch (mysqli_sql_exception $e) { printf("[014] %s\n", $e->getMessage()); } print "done!"; ?> --EXPECTF-- Warning: mysqli_multi_query(): (%d/%d): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'BAR; FOO' at line 1 in %s on line %d Warning: mysqli_query(): (%d/%d): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FOO' at line 1 in %s on line %d Warning: mysqli_change_user(): (%d/%d): Access denied for user '0123456789-10-456789-20-456789-%s'@'%s' (using password: YES) in %s on line %d Warning: mysqli_kill(): processid should have positive value in %s on line %d Warning: mysqli_real_query(): (%d/%d): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FOO' at line 1 in %s on line %d Warning: mysqli_kill(): processid should have positive value in %s on line %d [011] Access denied for user '%s'@'%s' (using password: YES) [014] Access denied for user '%s'@'%s' (using password: YES) done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_result_references.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_result_references.phpt +++ php-src/ext/mysqli/tests/mysqli_result_references.phpt --TEST-- References to result sets --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php require_once('connect.inc'); require_once('table.inc'); $references = array(); if (!(mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id ASC LIMIT 2")) || !($res = mysqli_store_result($link))) printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $idx = 0; while ($row = mysqli_fetch_assoc($res)) { /* mysqlnd: force seperation - create copies */ $references[$idx] = array( 'id' => &$row['id'], 'label' => $row['label'] . ''); $references[$idx++]['id'] += 0; } mysqli_close($link); mysqli_data_seek($res, 0); while ($row = mysqli_fetch_assoc($res)) { /* mysqlnd: force seperation - create copies */ $references[$idx] = array( 'id' => &$row['id'], 'label' => $row['label'] . ''); $references[$idx++]['id'] += 0; } mysqli_free_result($res); if (!$link = mysqli_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 (!(mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id ASC LIMIT 2")) || !($res = mysqli_use_result($link))) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); while ($row = mysqli_fetch_assoc($res)) { /* mysqlnd: force seperation - create copies*/ $references[$idx] = array( 'id' => &$row['id'], 'label' => $row['label'] . ''); $references[$idx]['id2'] = &$references[$idx]['id']; $references[$idx]['id'] += 1; $references[$idx++]['id2'] += 1; } $references[$idx++] = &$res; mysqli_free_result($res); debug_zval_dump($references); if (!(mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id ASC LIMIT 1")) || !($res = mysqli_use_result($link))) printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = array(); while ($row = mysqli_fetch_assoc($res)) { $tmp[] = $row; } $tmp = unserialize(serialize($tmp)); debug_zval_dump($tmp); mysqli_free_result($res); mysqli_close($link); print "done!"; ?> --EXPECTF-- array(7) refcount(2){ [0]=> array(2) refcount(1){ ["id"]=> long(1) refcount(1) ["label"]=> string(1) "a" refcount(1) } [1]=> array(2) refcount(1){ ["id"]=> long(2) refcount(1) ["label"]=> string(1) "b" refcount(1) } [2]=> array(2) refcount(1){ ["id"]=> long(1) refcount(1) ["label"]=> string(1) "a" refcount(1) } [3]=> array(2) refcount(1){ ["id"]=> long(2) refcount(1) ["label"]=> string(1) "b" refcount(1) } [4]=> array(3) refcount(1){ ["id"]=> &long(3) refcount(2) ["label"]=> string(1) "a" refcount(1) ["id2"]=> &long(3) refcount(2) } [5]=> array(3) refcount(1){ ["id"]=> &long(4) refcount(2) ["label"]=> string(1) "b" refcount(1) ["id2"]=> &long(4) refcount(2) } [6]=> &object(mysqli_result)#2 (0) refcount(2){ } } array(1) refcount(2){ [0]=> array(2) refcount(1){ ["id"]=> string(1) "1" refcount(1) ["label"]=> string(1) "a" refcount(1) } } done! --UEXPECTF-- array(7) refcount(2){ [0]=> array(2) refcount(1){ [u"id" { 0069 0064 }]=> long(1) refcount(1) [u"label" { 006c 0061 0062 0065 006c }]=> unicode(1) "a" { 0061 } refcount(1) } [1]=> array(2) refcount(1){ [u"id" { 0069 0064 }]=> long(2) refcount(1) [u"label" { 006c 0061 0062 0065 006c }]=> unicode(1) "b" { 0062 } refcount(1) } [2]=> array(2) refcount(1){ [u"id" { 0069 0064 }]=> long(1) refcount(1) [u"label" { 006c 0061 0062 0065 006c }]=> unicode(1) "a" { 0061 } refcount(1) } [3]=> array(2) refcount(1){ [u"id" { 0069 0064 }]=> long(2) refcount(1) [u"label" { 006c 0061 0062 0065 006c }]=> unicode(1) "b" { 0062 } refcount(1) } [4]=> array(3) refcount(1){ [u"id" { 0069 0064 }]=> &long(3) refcount(2) [u"label" { 006c 0061 0062 0065 006c }]=> unicode(1) "a" { 0061 } refcount(1) [u"id2" { 0069 0064 0032 }]=> &long(3) refcount(2) } [5]=> array(3) refcount(1){ [u"id" { 0069 0064 }]=> &long(4) refcount(2) [u"label" { 006c 0061 0062 0065 006c }]=> unicode(1) "b" { 0062 } refcount(1) [u"id2" { 0069 0064 0032 }]=> &long(4) refcount(2) } [6]=> &object(mysqli_result)#2 (0) refcount(2){ } } array(1) refcount(2){ [0]=> array(2) refcount(1){ [u"id" { 0069 0064 }]=> unicode(1) "1" { 0031 } refcount(1) [u"label" { 006c 0061 0062 0065 006c }]=> unicode(1) "a" { 0061 } refcount(1) } } done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_result_references_mysqlnd.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_result_references_mysqlnd.phpt +++ php-src/ext/mysqli/tests/mysqli_result_references_mysqlnd.phpt --TEST-- References to result sets - mysqlnd (no copies but references) --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('connect.inc'); if (!$IS_MYSQLND) die("skip Test for mysqlnd only"); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php require_once('connect.inc'); require_once('table.inc'); $references = array(); if (!(mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id ASC LIMIT 1")) || !($res = mysqli_store_result($link))) printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $idx = 0; while ($row = mysqli_fetch_assoc($res)) { /* will overwrite itself */ $references[$idx]['row_ref'] = &$row; $references[$idx]['row_copy'] = $row; $references[$idx]['id_ref'] = &$row['id']; $references[$idx++]['id_copy'] = $row['id']; } mysqli_free_result($res); if (!(mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id ASC LIMIT 2")) || !($res = mysqli_use_result($link))) printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $rows = array(); for ($i = 0; $i < 2; $i++) { $rows[$i] = mysqli_fetch_assoc($res); $references[$idx]['row_ref'] = &$rows[$i]; $references[$idx]['row_copy'] = $rows[$i]; $references[$idx]['id_ref'] = &$rows[$i]['id']; $references[$idx]['id_copy'] = $rows[$i]['id']; /* enforce seperation */ $references[$idx]['id_copy_mod']= $rows[$i]['id'] + 0; } mysqli_free_result($res); debug_zval_dump($references); print "done!"; ?> --EXPECTF-- array(2) refcount(2){ [0]=> array(4) refcount(1){ ["row_ref"]=> &NULL refcount(2) ["row_copy"]=> array(2) refcount(1){ ["id"]=> string(1) "1" refcount(2) ["label"]=> string(1) "a" refcount(2) } ["id_ref"]=> string(1) "1" refcount(1) ["id_copy"]=> string(1) "1" refcount(1) } [1]=> array(5) refcount(1){ ["row_ref"]=> &array(2) refcount(2){ ["id"]=> &string(1) "2" refcount(2) ["label"]=> string(1) "b" refcount(3) } ["row_copy"]=> array(2) refcount(1){ ["id"]=> string(1) "2" refcount(2) ["label"]=> string(1) "b" refcount(3) } ["id_ref"]=> &string(1) "2" refcount(2) ["id_copy"]=> string(1) "2" refcount(1) ["id_copy_mod"]=> long(2) refcount(1) } } done! --UEXPECTF-- array(2) refcount(2){ [0]=> array(4) refcount(1){ [u"row_ref" { 0072 006f 0077 005f 0072 0065 0066 }]=> &NULL refcount(2) [u"row_copy" { 0072 006f 0077 005f 0063 006f 0070 0079 }]=> array(2) refcount(1){ [u"id" { 0069 0064 }]=> unicode(1) "1" { 0031 } refcount(2) [u"label" { 006c 0061 0062 0065 006c }]=> unicode(1) "a" { 0061 } refcount(2) } [u"id_ref" { 0069 0064 005f 0072 0065 0066 }]=> unicode(1) "1" { 0031 } refcount(1) [u"id_copy" { 0069 0064 005f 0063 006f 0070 0079 }]=> unicode(1) "1" { 0031 } refcount(1) } [1]=> array(5) refcount(1){ [u"row_ref" { 0072 006f 0077 005f 0072 0065 0066 }]=> &array(2) refcount(2){ [u"id" { 0069 0064 }]=> &unicode(1) "2" { 0032 } refcount(2) [u"label" { 006c 0061 0062 0065 006c }]=> unicode(1) "b" { 0062 } refcount(3) } [u"row_copy" { 0072 006f 0077 005f 0063 006f 0070 0079 }]=> array(2) refcount(1){ [u"id" { 0069 0064 }]=> unicode(1) "2" { 0032 } refcount(2) [u"label" { 006c 0061 0062 0065 006c }]=> unicode(1) "b" { 0062 } refcount(3) } [u"id_ref" { 0069 0064 005f 0072 0065 0066 }]=> &unicode(1) "2" { 0032 } refcount(2) [u"id_copy" { 0069 0064 005f 0063 006f 0070 0079 }]=> unicode(1) "2" { 0032 } refcount(1) [u"id_copy_mod" { 0069 0064 005f 0063 006f 0070 0079 005f 006d 006f 0064 }]=> long(2) refcount(1) } } done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_rollback.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_rollback.phpt +++ php-src/ext/mysqli/tests/mysqli_rollback.phpt --TEST-- mysqli_rollback() --SKIPIF-- <?php ?> <?php ?> <?PHP require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('connect.inc'); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { die(sprintf("skip Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket)); } if (!$res = mysqli_query($link, "SHOW VARIABLES LIKE 'have_innodb'")) { die(sprintf("skip Cannot fetch have_innodb variable\n")); } $row = mysqli_fetch_row($res); mysqli_free_result($res); mysqli_close($link); if ($row[1] == "DISABLED" || $row[1] == "NO") { die(sprintf("skip Innodb support is not installed or enabled.")); } ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_rollback())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_rollback($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_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); if (!is_null($tmp = @mysqli_rollback($link, 'foo'))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = mysqli_autocommit($link, false))) printf("[005] Cannot turn off autocommit, expecting true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, 'CREATE TABLE test(id INT) ENGINE = InnoDB')) printf("[007] Cannot create test table, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, 'INSERT INTO test(id) VALUES (1)')) printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_rollback($link); if ($tmp !== true) printf("[009] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!$res = mysqli_query($link, 'SELECT COUNT(*) AS num FROM test')) printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); if (0 != $tmp['num']) printf("[12] Expecting 0 rows in table test, found %d rows\n", $tmp['num']); mysqli_free_result($res); if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_close($link); if (!is_null($tmp = mysqli_rollback($link))) printf("[014] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!\n"; ?> --EXPECTF-- Warning: mysqli_rollback(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_select_db.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_select_db.phpt +++ php-src/ext/mysqli/tests/mysqli_select_db.phpt --TEST-- mysqli_select_db() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_select_db())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_select_db($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_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); if (!is_null($tmp = @mysqli_select_db($link, $db, "foo"))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); /* does not make too much sense, unless we have access to at least one more database than $db */ if (!mysqli_select_db($link, $db)) printf("[005] Cannot select DB %s, [%d] %s\n", $db, mysqli_errno($link), mysqli_error($link)); if (!$res = mysqli_query($link, "SELECT DATABASE() AS dbname")) printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$row = mysqli_fetch_assoc($res)) printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if ($row['dbname'] !== (string)$db) printf("[008] Expecting database '%s', found '%s'\n", $db, $row['dbname']); mysqli_free_result($res); if (mysqli_select_db($link, 'mysql')) { // Yippie, a second database to play with - that's great because mysqli_select_db // ($db) was done by mysqli__connect() already and the previous test // was quite useless if (!$res = mysqli_query($link, "SELECT DATABASE() AS dbname")) printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$row = mysqli_fetch_assoc($res)) printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (strtolower($row['dbname']) !== 'mysql') printf("[011] Expecting database 'mysql', found '%s'\n", $row['dbname']); mysqli_free_result($res); } mysqli_report(MYSQLI_REPORT_OFF); mysqli_select_db($link, 'I can not imagine that this database exists'); mysqli_report(MYSQLI_REPORT_ERROR); mysqli_select_db($link, 'I can not imagine that this database exists'); mysqli_close($link); if (NULL !== ($tmp = mysqli_select_db($link, $db))) printf("[012] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!\n"; ?> --EXPECTF-- Warning: mysqli_select_db(): (%d/%d): Unknown database '%s' in %s on line %d Warning: mysqli_select_db(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_set_charset.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_set_charset.phpt +++ php-src/ext/mysqli/tests/mysqli_set_charset.phpt --TEST-- mysqli_set_charset() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); if (!function_exists('mysqli_set_charset')) die("skip Function not available"); if (ini_get("unicode.semantics")) die("skip: mysqli_set_charset() is disabled in unicode"); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_set_charset())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_set_charset($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_set_charset($link, $link))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysqli_query($link, 'SELECT version() AS server_version')) printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_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 = mysqli_query($link, 'SELECT @@character_set_connection AS charset, @@collation_connection AS collation')) printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); if (!$character_set_connection = $tmp['charset']) printf("[008] Cannot determine current character set and collation\n"); $new_charset = ('latin1' == $character_set_connection) ? 'latin2' : 'latin1'; if (!$res = mysqli_query($link, sprintf('SHOW CHARACTER SET LIKE "%s"', $new_charset), MYSQLI_STORE_RESULT)) printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (mysqli_num_rows($res) == 0) printf("[010] Test will fail, because alternative test character set '%s' seems not supported\n", $new_charset); if (false !== ($ret = mysqli_set_charset($link, "this is not a valid character set"))) printf("[011] Expecting boolean/false because of invalid character set, got %s/%s\n", gettype($ret), $ret); mysqli_close($link); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[012] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (true !== ($ret = mysqli_set_charset($link, $new_charset))) printf("[013] Expecting boolean/true, got %s/%s\n", gettype($ret), $ret); if (!$res = mysqli_query($link, 'SELECT @@character_set_connection AS charset, @@collation_connection AS collation')) printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); if ($new_charset !== $tmp['charset']) printf("[015] Character set not changed? Expecting %s, got %s\n", $new_charset, $tmp['charset']); if (!$res = mysqli_query($link, "SHOW CHARACTER SET")) printf("[016] Cannot get list of character sets\n"); while ($tmp = mysqli_fetch_assoc($res)) { if ('ucs2' == $tmp['Charset']) continue; /* Uncomment to see where it hangs - var_dump($tmp); flush(); */ if (!@mysqli_set_charset($link, $tmp['Charset'])) { printf("[017] Cannot set character set to '%s', [%d] %s\n", $tmp['Charset'], mysqli_errno($link), mysqli_error($link)); continue; } /* Uncomment to see where it hangs - var_dump($tmp); flush(); */ if (!mysqli_query($link, sprintf("SET NAMES %s", mysqli_real_escape_string($link, $tmp['Charset'])))) printf("[018] Cannot run SET NAMES %s, [%d] %s\n", $tmp['Charset'], mysqli_errno($link), mysqli_error($link)); } mysqli_free_result($res); mysqli_close($link); if (NULL !== ($tmp = mysqli_set_charset($link, $new_charset))) printf("[016] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_set_charset(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_set_opt.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_set_opt.phpt +++ php-src/ext/mysqli/tests/mysqli_set_opt.phpt --TEST-- mysqli_set_opt() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_set_opt())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_set_opt($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); $link = mysqli_init(); if (!is_null($tmp = @mysqli_set_opt($link, MYSQLI_OPT_CONNECT_TIMEOUT))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_set_opt($link, "s", 'extra_my.cnf'))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_set_opt($link, MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT=0', 'foo'))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); // print "run_tests.php don't fool me with your 'ungreedy' expression '.+?'!\n"; var_dump(mysqli_set_opt($link, MYSQLI_READ_DEFAULT_GROUP, 'extra_my.cnf')); var_dump(mysqli_set_opt($link, MYSQLI_READ_DEFAULT_FILE, 'extra_my.cnf')); var_dump(mysqli_set_opt($link, MYSQLI_OPT_CONNECT_TIMEOUT, 10)); var_dump(mysqli_set_opt($link, MYSQLI_OPT_LOCAL_INFILE, 1)); var_dump(mysqli_set_opt($link, MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT=0')); var_dump(mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)); var_dump(mysqli_set_opt($link, MYSQLI_READ_DEFAULT_GROUP, 'extra_my.cnf')); var_dump(mysqli_set_opt($link, MYSQLI_READ_DEFAULT_FILE, 'extra_my.cnf')); var_dump(mysqli_set_opt($link, MYSQLI_OPT_CONNECT_TIMEOUT, 10)); var_dump(mysqli_set_opt($link, MYSQLI_OPT_LOCAL_INFILE, 1)); var_dump(mysqli_set_opt($link, MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT=0')); var_dump(mysqli_set_opt($link, MYSQLI_CLIENT_SSL, 'not an mysqli_option')); mysqli_close($link); var_dump(mysqli_set_opt($link, MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT=1')); print "done!"; ?> --EXPECTF-- bool(true) bool(true) bool(true) bool(true) bool(true) bool(true) bool(true) bool(true) bool(true) bool(true) bool(true) bool(false) Warning: mysqli_set_opt(): Couldn't fetch mysqli in %s on line %d NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_set_opt_numeric_and_datetime_as_unicode.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_set_opt_numeric_and_datetime_as_unicode.phpt +++ php-src/ext/mysqli/tests/mysqli_set_opt_numeric_and_datetime_as_unicode.phpt --TEST-- mysqli_set_opt() - MYSQLI_OPT_NUMERIC_AND_DATETIME_AS_UNICODE --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); if (!function_exists('unicode_semantics')) die("skip needs PHP 6"); if (!unicode_semantics()) die("skip works only in unicode mode"); if (!stristr(mysqli_get_client_info(), "mysqlnd")) die("skip works only with mysqlnd"); ?> --FILE-- <?php include "connect.inc"; include "table.inc"; if (true !== ($tmp = mysqli_set_opt($link, MYSQLI_OPT_NUMERIC_AND_DATETIME_AS_UNICODE, 1))) printf("[001] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, 'ALTER TABLE test ADD col_date DATE, ADD col_time TIME, ADD col_timestamp TIMESTAMP, ADD col_datetime DATETIME')) printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, 'UPDATE test SET col_date = NOW(), col_time = NOW(), col_timestamp = NOW(), col_datetime = NOW()')) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$res = mysqli_query($link, 'SELECT * FROM test')) printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$row = mysqli_fetch_assoc($res)) printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_unicode($row['col_time']) || '' == $row['col_time']) printf("[006] Expecting unicode/any, got %s/%s\n", gettype($row['col_time']), $row['col_time']); if (!is_unicode($row['col_timestamp']) || '' == $row['col_timestamp']) printf("[007] Expecting unicode/any, got %s/%s\n", gettype($row['col_timestamp']), $row['col_timestamp']); if (!is_unicode($row['col_datetime']) || '' == $row['col_datetime']) printf("[008] Expecting unicode/any, got %s/%s\n", gettype($row['col_datetime']), $row['col_datetime']); if (!is_unicode($row['col_date']) || '' == $row['col_date']) printf("[009] Expecting unicode/any, got %s/%s\n", gettype($row['col_date']), $row['col_date']); mysqli_free_result($res); if (true !== ($tmp = mysqli_set_opt($link, MYSQLI_OPT_NUMERIC_AND_DATETIME_AS_UNICODE, 0))) printf("[010] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!$res = mysqli_query($link, 'SELECT * FROM test')) printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$row = mysqli_fetch_assoc($res)) printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (is_unicode($row['col_time']) || '' == $row['col_time']) printf("[013] Expecting (binary) string/any, got %s/%s\n", gettype($row['col_time']), $row['col_time']); if (is_unicode($row['col_timestamp']) || '' == $row['col_timestamp']) printf("[014] Expecting (binary) string/any, got %s/%s\n", gettype($row['col_timestamp']), $row['col_timestamp']); if (is_unicode($row['col_datetime']) || '' == $row['col_datetime']) printf("[015] Expecting (binary) string/any, got %s/%s\n", gettype($row['col_datetime']), $row['col_datetime']); if (is_unicode($row['col_date']) || '' == $row['col_date']) printf("[016] Expecting (binary) string/any, got %s/%s\n", gettype($row['col_date']), $row['col_date']); mysqli_free_result($res); if (true !== ($tmp = mysqli_set_opt($link, MYSQLI_OPT_NUMERIC_AND_DATETIME_AS_UNICODE, 1))) printf("[017] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!$res = mysqli_query($link, 'SELECT * FROM test')) printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$row = mysqli_fetch_assoc($res)) printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_unicode($row['col_time']) || '' == $row['col_time']) printf("[020] Expecting unicode/any, got %s/%s\n", gettype($row['col_time']), $row['col_time']); mysqli_free_result($res); if (!$stmt = mysqli_stmt_init($link)) printf("[021] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $col_date = $col_time = $col_datetime = $col_timestamp = null; if (!mysqli_stmt_prepare($stmt, 'SELECT col_date, col_time, col_datetime, col_timestamp FROM test') || !mysqli_stmt_execute($stmt) || !mysqli_stmt_bind_result($stmt, $col_date, $col_time, $col_datetime, $col_timestamp) || !mysqli_stmt_fetch($stmt)) printf("[022] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!is_unicode($col_date) || '' == $col_date) printf("[023] Expecting unicode/any, got %s/%s\n", gettype($col_date), $col_date); if (!is_unicode($col_time) || '' == $col_time) printf("[024] Expecting unicode/any, got %s/%s\n", gettype($col_time), $col_time); if (!is_unicode($col_datetime) || '' == $col_datetime) printf("[025] Expecting unicode/any, got %s/%s\n", gettype($col_datetime), $col_datetime); if (!is_unicode($col_timestamp) || '' == $col_timestamp) printf("[026] Expecting unicode/any, got %s/%s\n", gettype($col_timestamp), $col_timestamp); mysqli_stmt_close($stmt); if (true !== ($tmp = mysqli_set_opt($link, MYSQLI_OPT_NUMERIC_AND_DATETIME_AS_UNICODE, 0))) printf("[027] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!$stmt = mysqli_stmt_init($link)) printf("[028] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $col_date = $col_time = $col_datetime = $col_timestamp = null; if (!mysqli_stmt_prepare($stmt, 'SELECT col_date, col_time, col_datetime, col_timestamp FROM test') || !mysqli_stmt_execute($stmt) || !mysqli_stmt_bind_result($stmt, $col_date, $col_time, $col_datetime, $col_timestamp) || !mysqli_stmt_fetch($stmt)) printf("[029] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (is_unicode($col_date) || '' == $col_date) printf("[030] Expecting (binary) string/any, got %s/%s\n", gettype($col_date), $col_date); if (is_unicode($col_time) || '' == $col_time) printf("[031] Expecting (binary) string/any, got %s/%s\n", gettype($col_time), $col_time); if (is_unicode($col_datetime) || '' == $col_datetime) printf("[032] Expecting (binary) string/any, got %s/%s\n", gettype($col_datetime), $col_datetime); if (is_unicode($col_timestamp) || '' == $col_timestamp) printf("[033] Expecting (binary) string/any, got %s/%s\n", gettype($col_timestamp), $col_timestamp); mysqli_stmt_close($stmt); mysqli_close($link); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_sqlstate.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_sqlstate.phpt +++ php-src/ext/mysqli/tests/mysqli_sqlstate.phpt --TEST-- mysqli_sqlstate() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_sqlstate())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_sqlstate($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); var_dump(@mysqli_sqlstate($link, "foo")); var_dump(mysqli_sqlstate($link)); mysqli_query($link, "SELECT unknown_column FROM test"); var_dump(mysqli_sqlstate($link)); mysqli_free_result(mysqli_query($link, "SELECT id FROM test")); var_dump(mysqli_sqlstate($link)); mysqli_close($link); var_dump(mysqli_sqlstate($link)); print "done!"; ?> --EXPECTF-- NULL %s(5) "00000" %s(5) "42S22" %s(5) "00000" Warning: mysqli_sqlstate(): Couldn't fetch mysqli in %s on line %d NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_ssl_set.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_ssl_set.phpt +++ php-src/ext/mysqli/tests/mysqli_ssl_set.phpt --TEST-- mysqli_ssl_set() - test is a stub! --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); if (!function_exists('mysqli_ssl_set')) die("skip function not available"); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_ssl_set())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_ssl_set($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_ssl_set($link, $link))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_ssl_set($link, $link, $link))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_ssl_set($link, $link, $link, $link))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_ssl_set($link, $link, $link, $link, $link))) printf("[006] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); /* This function always returns TRUE value. $link = mysqli_init(); if (NULL !== ($tmp = @mysqli_ssl_set( $link, 'The path name to the key file.', 'The path name to the certificate file.', 'The path name to the certificate authority file.', 'The pathname to a directory that contains trusted SSL CA certificates in PEM format.', 'A list of allowable ciphers to use for SSL encryption.'))) printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); If SSL setup is incorrect mysqli_real_connect() will return an error when you attempt to connect. ... and the above SSL setup should be always incorrect. if (false !== ($tmp = mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))) printf("[008] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); */ print "done!\n"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stat.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stat.phpt +++ php-src/ext/mysqli/tests/mysqli_stat.phpt --TEST-- mysqli_stat() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stat())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stat($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!is_null($tmp = @mysqli_stat($link, "foo"))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if ((!is_string($tmp = mysqli_stat($link))) || ('' === $tmp)) printf("[004] Expecting non empty string, got %s/'%s', [%d] %s\n", gettype($tmp), $tmp, mysqli_errno($link), mysql_error($link)); mysqli_close($link); if (!is_null($tmp = mysqli_stat($link))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_stat(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_affected_rows.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_affected_rows.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_affected_rows.phpt --TEST-- mysqli_stmt_affected_rows() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_affected_rows())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_affected_rows($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { printf("Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); } $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, 'DROP TABLE IF EXISTS test') || !mysqli_stmt_execute($stmt)) { printf("[003] Failed to drop old test table: [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); } if (!mysqli_stmt_prepare($stmt, 'CREATE TABLE test(id INT, label CHAR(1), PRIMARY KEY(id)) ENGINE = ' . $engine) || !mysqli_stmt_execute($stmt)) { printf("[004] Failed to create test table: [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); } if (0 !== ($tmp = mysqli_stmt_affected_rows($stmt))) printf("[005] Expecting int/0, got %s/'%s'\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, 'INSERT INTO test(id, label) VALUES (1, "a")') || !mysqli_stmt_execute($stmt)) printf("[006] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); mysqli_stmt_close($stmt); $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, 'INSERT INTO test(id, label) VALUES (100, "z")') || !mysqli_stmt_execute($stmt)) printf("[007] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (1 !== ($tmp = mysqli_stmt_affected_rows($stmt))) printf("[008] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, 'INSERT INTO test(id, label) VALUES (100, "z")') || !mysqli_stmt_execute($stmt)) // NOTE: the error message varies with the MySQL Server version, dump only the error code! printf("[009] [%d] (error message varies with the MySQL Server version, check the error code)\n", mysqli_stmt_errno($stmt)); /* an error occured: affected rows should return -1 */ if (-1 !== ($tmp = mysqli_stmt_affected_rows($stmt))) printf("[010] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, 'INSERT INTO test(id, label) VALUES (1, "a") ON DUPLICATE KEY UPDATE id = 4') || !mysqli_stmt_execute($stmt)) printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (2 !== ($tmp = mysqli_stmt_affected_rows($stmt))) printf("[012] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (2, 'b'), (3, 'c')") || !mysqli_stmt_execute($stmt)) printf("[013] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (2 !== ($tmp = mysqli_stmt_affected_rows($stmt))) printf("[014] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, "INSERT IGNORE INTO test(id, label) VALUES (1, 'a')") || !mysqli_stmt_execute($stmt)) printf("[015] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (1 !== ($tmp = mysqli_stmt_affected_rows($stmt))) printf("[016] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); if (!($res = mysqli_query($link, "SELECT count(id) AS num FROM test")) || !($tmp = mysqli_fetch_assoc($res))) printf("[017] [%d] %s\n", mysqli_errnor($link), mysqli_error($link)); $num = (int)$tmp['num']; mysqli_free_result($res); mysqli_stmt_close($stmt); $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) SELECT id + 10, label FROM test") || !mysqli_stmt_execute($stmt)) printf("[018] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if ($num !== ($tmp = mysqli_stmt_affected_rows($stmt))) printf("[019] Expecting int/%d, got %s/%s\n", $num, gettype($tmp), $tmp); mysqli_stmt_close($stmt); $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, "REPLACE INTO test(id, label) values (4, 'd')") || !mysqli_stmt_execute($stmt)) printf("[020] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (2 !== ($tmp = mysqli_stmt_affected_rows($stmt))) printf("[021] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, "REPLACE INTO test(id, label) values (5, 'e')") || !mysqli_stmt_execute($stmt)) printf("[022] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (1 !== ($tmp = mysqli_stmt_affected_rows($stmt))) printf("[023] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, "UPDATE test SET label = 'a' WHERE id = 2") || !mysqli_stmt_execute($stmt)) printf("[024] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (1 !== ($tmp = mysqli_stmt_affected_rows($stmt))) printf("[025] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, "UPDATE test SET label = 'a' WHERE id = 2") || !mysqli_stmt_execute($stmt)) printf("[026] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (0 !== ($tmp = mysqli_stmt_affected_rows($stmt))) printf("[027] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, "UPDATE test SET label = 'a' WHERE id = 100") || !mysqli_stmt_execute($stmt)) printf("[028] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (1 !== ($tmp = mysqli_stmt_affected_rows($stmt))) printf("[029] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, "DROP TABLE IF EXISTS test") || !mysqli_stmt_execute($stmt)) printf("[030] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); mysqli_stmt_close($stmt); if (!is_null($tmp = mysqli_stmt_affected_rows($stmt))) printf("[031] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); print "done!"; ?> --EXPECTF-- [009] [%d] (error message varies with the MySQL Server version, check the error code) Warning: mysqli_stmt_affected_rows(): Couldn't fetch mysqli_stmt in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_attr_get.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_attr_get.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_attr_get.phpt --TEST-- mysqli_stmt_attr_get() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_attr_get())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_attr_get($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_attr_get($link, $link))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!is_null($tmp = @mysqli_stmt_attr_get($link, $link))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); $valid_attr = array("max_length" => MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH); if (mysqli_get_client_version() > 50003) $valid_attr["cursor_type"] = MYSQLI_STMT_ATTR_CURSOR_TYPE; if ($IS_MYSQLND && mysqli_get_client_version() > 50007) $valid_attr["prefetch_rows"] = MYSQLI_STMT_ATTR_PREFETCH_ROWS; do { $invalid_attr = mt_rand(0, 10000); } while (in_array($invalid_attr, $valid_attr)); $stmt = mysqli_stmt_init($link); mysqli_stmt_prepare($stmt, 'SELECT * FROM test'); if (false !== ($tmp = @mysqli_stmt_attr_get($stmt, $invalid_attr))) printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); foreach ($valid_attr as $k => $attr) { if (false === ($tmp = mysqli_stmt_attr_get($stmt, $attr))) { printf("[006] Expecting any type, but not boolean/false, got %s/%s for attribute %s/%s\n", gettype($tmp), $tmp, $k, $attr); } } $stmt->close(); foreach ($valid_attr as $k => $attr) { if (!is_null($tmp = @mysqli_stmt_attr_get($stmt, $attr))) { printf("[007] Expecting NULL/NULL, got %s/%s for attribute %s/%s\n", gettype($tmp), $tmp, $k, $attr); } } mysqli_close($link); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_attr_get_prefetch.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_attr_get_prefetch.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_attr_get_prefetch.phpt --TEST-- mysqli_stmt_attr_get() - prefetch --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> <?php die("SKIP: prefetch isn't supported at the moment") ?> --FILE-- <?php include "connect.inc"; require('table.inc'); $stmt = mysqli_stmt_init($link); mysqli_stmt_prepare($stmt, 'SELECT * FROM test'); if (1 !== ($tmp = mysqli_stmt_attr_get($stmt, MYSQLI_STMT_ATTR_PREFETCH_ROWS))) { printf("[001] Expecting int/1, got %s/%s for attribute %s/%s\n", gettype($tmp), $tmp, $k, $attr); } $stmt->close(); mysqli_close($link); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_attr_set.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_attr_set.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_attr_set.phpt --TEST-- mysqli_stmt_attr_set() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_attr_set())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_attr_set($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_attr_set($link, $link))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_attr_set($link, $link, $link))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); $valid_attr = array(MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH); if (mysqli_get_client_version() > 50003) $valid_attr[] = MYSQLI_STMT_ATTR_CURSOR_TYPE; /* prefetch isn't supported if (mysqli_get_client_version() > 50007) $valid_attr[] = MYSQLI_STMT_ATTR_PREFETCH_ROWS; */ do { $invalid_attr = mt_rand(-10000, 10000); } while (in_array($invalid_attr, $valid_attr)); $stmt = mysqli_stmt_init($link); if (!is_null($tmp = @mysqli_stmt_attr_set($stmt, 0, 0))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); $stmt->prepare("SELECT * FROM test"); if (false !== ($tmp = @mysqli_stmt_attr_set($stmt, $invalid_attr, 0))) printf("[006] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); $stmt->close(); // // MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH // // expecting max_length not to be set and be 0 in all cases $stmt = mysqli_stmt_init($link); $stmt->prepare("SELECT label FROM test"); $stmt->execute(); $stmt->store_result(); $res = $stmt->result_metadata(); $fields = $res->fetch_fields(); $max_lengths = array(); foreach ($fields as $k => $meta) { $max_lengths[$meta->name] = $meta->max_length; if ($meta->max_length !== 0) printf("[007] max_length should be not set (= 0), got %s for field %s\n", $meta->max_length, $meta->name); } $res->close(); $stmt->close(); // expecting max_length to _be_ set $stmt = mysqli_stmt_init($link); $stmt->prepare("SELECT label FROM test"); $stmt->attr_set(MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH, 1); $stmt->execute(); $stmt->store_result(); $res = $stmt->result_metadata(); $fields = $res->fetch_fields(); $max_lengths = array(); foreach ($fields as $k => $meta) { $max_lengths[$meta->name] = $meta->max_length; if ($meta->max_length === 0) printf("[008] max_length should be set (!= 0), got %s for field %s\n", $meta->max_length, $meta->name); } $res->close(); $stmt->close(); // expecting max_length not to be set $stmt = mysqli_stmt_init($link); $stmt->prepare("SELECT label FROM test"); $stmt->attr_set(MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH, 0); $stmt->execute(); $stmt->store_result(); $res = $stmt->result_metadata(); $fields = $res->fetch_fields(); $max_lengths = array(); foreach ($fields as $k => $meta) { $max_lengths[$meta->name] = $meta->max_length; if ($meta->max_length !== 0) printf("[009] max_length should not be set (= 0), got %s for field %s\n", $meta->max_length, $meta->name); } $res->close(); $stmt->close(); // // Cursors // if (mysqli_get_client_version() > 50003) { $cursor_types = array( MYSQLI_CURSOR_TYPE_NO_CURSOR, MYSQLI_CURSOR_TYPE_READ_ONLY, MYSQLI_CURSOR_TYPE_FOR_UPDATE, MYSQLI_CURSOR_TYPE_SCROLLABLE ); do { $invalid_cursor_type = mt_rand(-1000, 1000); } while (in_array($invalid_cursor_type, $cursor_types)); $stmt = mysqli_stmt_init($link); $stmt->prepare("SELECT id, label FROM test"); if (false !== ($tmp = @$stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, $invalid_cursor_type))) printf("[010] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_FOR_UPDATE))) printf("[011] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_SCROLLABLE))) printf("[012] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_NO_CURSOR))) printf("[013] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_READ_ONLY))) printf("[014] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); $stmt->close(); $stmt = mysqli_stmt_init($link); $stmt->prepare("SELECT id, label FROM test"); $stmt->execute(); $id = $label = NULL; $stmt->bind_result($id, $label); $results = array(); while ($stmt->fetch()) $results[$id] = $label; $stmt->close(); if (empty($results)) printf("[015] Results should not be empty, subsequent tests will probably fail!\n"); $stmt = mysqli_stmt_init($link); $stmt->prepare("SELECT id, label FROM test"); if (true !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_NO_CURSOR))) printf("[016] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); $stmt->execute(); $id = $label = NULL; $stmt->bind_result($id, $label); $results2 = array(); while ($stmt->fetch()) $results2[$id] = $label; $stmt->close(); if ($results != $results2) { printf("[017] Results should not differ. Dumping both result sets.\n"); var_dump($results); var_dump($results2); } $stmt = mysqli_stmt_init($link); $stmt->prepare("SELECT id, label FROM test"); if (true !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_READ_ONLY))) printf("[018] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); $stmt->execute(); $id = $label = NULL; $stmt->bind_result($id, $label); $results2 = array(); while ($stmt->fetch()) $results2[$id] = $label; $stmt->close(); if ($results != $results2) { printf("[019] Results should not differ. Dumping both result sets.\n"); var_dump($results); var_dump($results2); } } // // MYSQLI_STMT_ATTR_PREFETCH_ROWS // if (mysqli_get_client_version() > 50007) { $stmt = mysqli_stmt_init($link); $stmt->prepare("SELECT id, label FROM test"); if (true !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_PREFETCH_ROWS, 1))) printf("[020] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); $stmt->execute(); $id = $label = NULL; $stmt->bind_result($id, $label); $results = array(); while ($stmt->fetch()) $results[$id] = $label; $stmt->close(); if (empty($results)) printf("[021] Results should not be empty, subsequent tests will probably fail!\n"); /* prefetch is not supported $stmt = mysqli_stmt_init($link); $stmt->prepare("SELECT label FROM test"); if (false !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_PREFETCH_ROWS, -1))) printf("[022] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); $stmt->close(); $stmt = mysqli_stmt_init($link); $stmt->prepare("SELECT label FROM test"); if (true !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_PREFETCH_ROWS, PHP_INT_MAX))) printf("[023] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); $stmt->close(); $stmt = mysqli_stmt_init($link); $stmt->prepare("SELECT id, label FROM test"); if (true !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_PREFETCH_ROWS, 2))) printf("[024] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); $stmt->execute(); $id = $label = NULL; $stmt->bind_result($id, $label); $results2 = array(); while ($stmt->fetch()) $results2[$id] = $label; $stmt->close(); if ($results != $results2) { printf("[025] Results should not differ. Dumping both result sets.\n"); var_dump($results); var_dump($results2); } */ } mysqli_close($link); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_bind_param.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_bind_param.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_bind_param.phpt --TEST-- mysqli_stmt_bind_param() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php /* The way we test the INSERT and data types overlaps with the mysqli_stmt_bind_result test in large parts. There is only one difference. This test uses mysqli_query()/mysqli_fetch_assoc() to fetch the inserted values. This way we test mysqli_query()/mysqli_fetch_assoc() for all possible data types in this file and we test mysqli_stmt_bind_result() in the other test -- therefore the "duplicate" makes some sense to me. */ include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_bind_param())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_bind_param($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_bind_param($link, $link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) printf("[003] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); $id = null; $label = null; /* libmysql gives a less descriptive error message but mysqlnd, we did not unify the error messages but ignore this slight difference silently */ if (!false === ($tmp = @mysqli_stmt_bind_param($stmt, "", $id, $label))) printf("[003a] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); /* TODO: somehwhat undocumented syntax! */ $param = array($id); if (!false === ($tmp = mysqli_stmt_bind_param($stmt, "is", $param))) printf("[003b] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); $param = array($id, $label, $id); if (!false === ($tmp = mysqli_stmt_bind_param($stmt, "is", $param))) printf("[003c] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (!false === ($tmp = mysqli_stmt_bind_param($stmt, "a", $id))) printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (!false === ($tmp = mysqli_stmt_bind_param($stmt, "a", $id, $label))) printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (!false === ($tmp = mysqli_stmt_bind_param($stmt, "aa", $id, $label))) printf("[006] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (!false === ($tmp = mysqli_stmt_bind_param($stmt, "ia", $id, $label))) printf("[007] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (!true === ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label))) printf("[008] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (function_exists("memory_get_usage")) { $mem = memory_get_usage(); for ($i = 0; $i < 20000; $i++) { if (!true === ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label))) printf("[008][$i] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); } if (($tmp = (memory_get_usage() - $mem)) > 600) printf("[009] Function seems to be leaking, because it used %d bytes. During tests it used only 92 bytes.", $tmp); } $id = 100; $label = "z"; if (!mysqli_stmt_execute($stmt)) printf("[010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); mysqli_stmt_close($stmt); if (!($res = mysqli_query($link, "SELECT id, label FROM test WHERE id = " . $id))) printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $row = mysqli_fetch_assoc($res); if (($row['id'] != $id) || ($row['label'] != $label)) printf("[012] Expecting '%s'/%s', got '%s'/%s'!\n", $id, $label, $row['id'], $row['label']); mysqli_free_result($res); function func_mysqli_stmt_bind_datatype($link, $engine, $bind_type, $sql_type, $bind_value, $offset, $alternative = null) { if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) { printf("[%03d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link)); return false; } if (!mysqli_query($link, sprintf("CREATE TABLE test(id INT NOT NULL, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) { // don't bail - it might be that the server does not support the data type return false; } if (!$stmt = mysqli_stmt_init($link)) { printf("[%03d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link)); return false; } if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUE (?, ?)")) { printf("[%03d] [%d] %s\n", $offset + 2, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); return false; } $id = 1; if (!mysqli_stmt_bind_param($stmt, "i" . $bind_type, $id, $bind_value)) { printf("[%03d] [%d] %s\n", $offset + 3, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); return false; } if (!mysqli_stmt_execute($stmt)) { printf("[%03d] [%d] %s\n", $offset + 4, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); return false; } mysqli_stmt_close($stmt); if (!$res = mysqli_query($link, "SELECT id, label FROM test")) { printf("[%03d] [%d] %s\n", $offset + 5, mysqli_errno($link), mysqli_error($link)); return false; } if (!$row = mysqli_fetch_assoc($res)) { printf("[%03d] [%d] %s\n", $offset + 5, mysqli_errno($link), mysqli_error($link)); return false; } if ($alternative) { if (($row['id'] != $id) || (($row['label'] != $bind_value) && ($row['label'] != $alternative))) { printf("[%03d] Testing '%s', '%s': expecting '%s'/'%s' (%s), got '%s'/'%s'\n", $offset + 6, $bind_type, $sql_type, $id, $bind_value, gettype($bind_value), $row['id'], $row['label']); return false; } } else { if (($row['id'] != $id) || ($row['label'] != $bind_value)) { printf("[%03d] Testing '%s', '%s': expecting '%s'/'%s', got '%s'/'%s'\n", $offset + 6, $bind_type, $sql_type, $id, $bind_value, $row['id'], $row['label']); return false; } } mysqli_free_result($res); return true; } function func_mysqli_stmt_bind_make_string($len) { $ret = ''; for ($i = 0; $i < $len; $i++) $ret .= chr(mt_rand(65, 90)); return $ret; } func_mysqli_stmt_bind_datatype($link, $engine, "i", "TINYINT", -11, 20); func_mysqli_stmt_bind_datatype($link, $engine, "i", "TINYINT", NULL, 30); func_mysqli_stmt_bind_datatype($link, $engine, "i", "TINYINT UNSIGNED", 1, 40); func_mysqli_stmt_bind_datatype($link, $engine, "i", "TINYINT UNSIGNED", NULL, 50); func_mysqli_stmt_bind_datatype($link, $engine, "i", "BOOL", 1, 60); func_mysqli_stmt_bind_datatype($link, $engine, "i", "BOOL", NULL, 70); func_mysqli_stmt_bind_datatype($link, $engine, "i", "BOOLEAN", 0, 80); func_mysqli_stmt_bind_datatype($link, $engine, "i", "BOOLEAN", NULL, 90); func_mysqli_stmt_bind_datatype($link, $engine, "i", "SMALLINT", -32768, 100); func_mysqli_stmt_bind_datatype($link, $engine, "i", "SMALLINT", 32767, 110); func_mysqli_stmt_bind_datatype($link, $engine, "i", "SMALLINT", NULL, 120); func_mysqli_stmt_bind_datatype($link, $engine, "i", "SMALLINT UNSIGNED", 65535, 130); func_mysqli_stmt_bind_datatype($link, $engine, "i", "SMALLINT UNSIGNED", NULL, 140); func_mysqli_stmt_bind_datatype($link, $engine, "i", "MEDIUMINT", -8388608, 150); func_mysqli_stmt_bind_datatype($link, $engine, "i", "MEDIUMINT", 8388607, 160); func_mysqli_stmt_bind_datatype($link, $engine, "i", "MEDIUMINT", NULL, 170); func_mysqli_stmt_bind_datatype($link, $engine, "i", "MEDIUMINT UNSIGNED", 16777215, 180); func_mysqli_stmt_bind_datatype($link, $engine, "i", "MEDIUMINT UNSIGNED", NULL, 190); func_mysqli_stmt_bind_datatype($link, $engine, "i", "INTEGER", -2147483648, 200); func_mysqli_stmt_bind_datatype($link, $engine, "i", "INTEGER", 2147483647, 210); func_mysqli_stmt_bind_datatype($link, $engine, "i", "INTEGER", NULL, 220); func_mysqli_stmt_bind_datatype($link, $engine, "i", "INTEGER UNSIGNED", (defined("PHP_INT_MAX")) ? min(4294967295, PHP_INT_MAX) : 1, 230); func_mysqli_stmt_bind_datatype($link, $engine, "d", "INTEGER UNSIGNED", 4294967295, 240); func_mysqli_stmt_bind_datatype($link, $engine, "i", "INTEGER UNSIGNED", NULL, 250); func_mysqli_stmt_bind_datatype($link, $engine, "i", "BIGINT", -1 * PHP_INT_MAX + 1, 260); func_mysqli_stmt_bind_datatype($link, $engine, "i", "BIGINT", NULL, 270); func_mysqli_stmt_bind_datatype($link, $engine, "i", "BIGINT", PHP_INT_MAX, 280); func_mysqli_stmt_bind_datatype($link, $engine, "i", "BIGINT UNSIGNED", NULL, 290); func_mysqli_stmt_bind_datatype($link, $engine, "s", "BIGINT", "-9223372036854775808", 900); // ?? func_mysqli_stmt_bind_datatype($link, $engine, "d", "BIGINT", -9223372036854775808, 910); func_mysqli_stmt_bind_datatype($link, $engine, "s", "BIGINT UNSIGNED", "18446744073709551615", 920); /* ?? func_mysqli_stmt_bind_datatype($link, $engine, "d", "FLOAT", -9223372036854775808 - 1.1, 300); func_mysqli_stmt_bind_datatype($link, $engine, "d", "FLOAT UNSIGNED", 18446744073709551615 + 1.1, 320); */ func_mysqli_stmt_bind_datatype($link, $engine, "d", "FLOAT", NULL, 310); func_mysqli_stmt_bind_datatype($link, $engine, "d", "FLOAT UNSIGNED ", NULL, 330); if (2147483647 == PHP_INT_MAX) { func_mysqli_stmt_bind_datatype($link, $engine, "d", "FLOAT UNSIGNED", PHP_INT_MAX, 930, '2.14748e+09'); func_mysqli_stmt_bind_datatype($link, $engine, "d", "FLOAT", -1 * PHP_INT_MAX + 1, 940, '-2.14748e+09'); } func_mysqli_stmt_bind_datatype($link, $engine, "s", "FLOAT", "-9223372036854775808", 300, '-9.22337e+18'); func_mysqli_stmt_bind_datatype($link, $engine, "s", "FLOAT UNSIGNED", "18446744073709551615", 320, '1.84467e+19'); func_mysqli_stmt_bind_datatype($link, $engine, "d", "FLOAT", -10.01, 950); func_mysqli_stmt_bind_datatype($link, $engine, "d", "FLOAT UNSIGNED", 10.01, 960); func_mysqli_stmt_bind_datatype($link, $engine, "d", "DOUBLE(10,2)", NULL, 350); func_mysqli_stmt_bind_datatype($link, $engine, "d", "DOUBLE(10,2) UNSIGNED", NULL, 370); func_mysqli_stmt_bind_datatype($link, $engine, "d", "DOUBLE(10,2)", -99999999.99, 340); func_mysqli_stmt_bind_datatype($link, $engine, "d", "DOUBLE(10,2) UNSIGNED", 99999999.99, 360); /* func_mysqli_stmt_bind_datatype($link, $engine, "d", "DOUBLE(10,2)", -99999999.99, 340); func_mysqli_stmt_bind_datatype($link, $engine, "d", "DOUBLE(10,2) UNSIGNED", 99999999.99, 360); */ func_mysqli_stmt_bind_datatype($link, $engine, "d", "DECIMAL(10,2)", -99999999.99, 380); func_mysqli_stmt_bind_datatype($link, $engine, "d", "DECIMAL(10,2)", NULL, 390); func_mysqli_stmt_bind_datatype($link, $engine, "d", "DECIMAL(10,2)", 99999999.99, 400); func_mysqli_stmt_bind_datatype($link, $engine, "d", "DECIMAL(10,2)", NULL, 410); // don't care about date() strict TZ warnings... func_mysqli_stmt_bind_datatype($link, $engine, "s", "DATE", @date('Y-m-d'), 420); func_mysqli_stmt_bind_datatype($link, $engine, "s", "DATE NOT NULL", @date('Y-m-d'), 430); func_mysqli_stmt_bind_datatype($link, $engine, "s", "DATE", NULL, 440); func_mysqli_stmt_bind_datatype($link, $engine, "s", "DATETIME", @date('Y-m-d H:i:s'), 450); func_mysqli_stmt_bind_datatype($link, $engine, "s", "DATETIME NOT NULL", @date('Y-m-d H:i:s'), 460); func_mysqli_stmt_bind_datatype($link, $engine, "s", "DATETIME", NULL, 470); func_mysqli_stmt_bind_datatype($link, $engine, "s", "TIMESTAMP", @date('Y-m-d H:i:s'), 480); func_mysqli_stmt_bind_datatype($link, $engine, "s", "TIME", @date('H:i:s'), 490); func_mysqli_stmt_bind_datatype($link, $engine, "s", "TIME NOT NULL", @date('H:i:s'), 500); func_mysqli_stmt_bind_datatype($link, $engine, "s", "TIME", NULL, 510); func_mysqli_stmt_bind_datatype($link, $engine, "s", "YEAR", @date('Y'), 520); func_mysqli_stmt_bind_datatype($link, $engine, "s", "YEAR NOT NULL", @date('Y'), 530); func_mysqli_stmt_bind_datatype($link, $engine, "s", "YEAR", NULL, 540); $string255 = func_mysqli_stmt_bind_make_string(255); func_mysqli_stmt_bind_datatype($link, $engine, "s", "CHAR(1)", "a", 550); func_mysqli_stmt_bind_datatype($link, $engine, "s", "CHAR(255)", $string255, 560); func_mysqli_stmt_bind_datatype($link, $engine, "s", "CHAR(1) NOT NULL", "a", 570); func_mysqli_stmt_bind_datatype($link, $engine, "s", "CHAR(1)", NULL, 580); $string65k = func_mysqli_stmt_bind_make_string(65535); func_mysqli_stmt_bind_datatype($link, $engine, "s", "VARCHAR(1)", "a", 590); func_mysqli_stmt_bind_datatype($link, $engine, "s", "VARCHAR(255)", $string255, 600); func_mysqli_stmt_bind_datatype($link, $engine, "s", "VARCHAR(65635)", $string65k, 610); func_mysqli_stmt_bind_datatype($link, $engine, "s", "VARCHAR(1) NOT NULL", "a", 620); func_mysqli_stmt_bind_datatype($link, $engine, "s", "VARCHAR(1)", NULL, 630); func_mysqli_stmt_bind_datatype($link, $engine, "s", "BINARY(1)", "a", 640); func_mysqli_stmt_bind_datatype($link, $engine, "s", "BINARY(1)", chr(0), 650); func_mysqli_stmt_bind_datatype($link, $engine, "s", "BINARY(1) NOT NULL", "b", 660); func_mysqli_stmt_bind_datatype($link, $engine, "s", "BINARY(1)", NULL, 670); func_mysqli_stmt_bind_datatype($link, $engine, "s", "VARBINARY(1)", "a", 680); func_mysqli_stmt_bind_datatype($link, $engine, "s", "VARBINARY(1)", chr(0), 690); func_mysqli_stmt_bind_datatype($link, $engine, "s", "VARBINARY(1) NOT NULL", "b", 700); func_mysqli_stmt_bind_datatype($link, $engine, "s", "VARBINARY(1)", NULL, 710); func_mysqli_stmt_bind_datatype($link, $engine, "s", "TINYBLOB", "a", 720); func_mysqli_stmt_bind_datatype($link, $engine, "s", "TINYBLOB", chr(0), 730); func_mysqli_stmt_bind_datatype($link, $engine, "s", "TINYBLOB NOT NULL", "b", 740); func_mysqli_stmt_bind_datatype($link, $engine, "s", "TINYBLOB", NULL, 750); func_mysqli_stmt_bind_datatype($link, $engine, "s", "TINYTEXT", "a", 760); func_mysqli_stmt_bind_datatype($link, $engine, "s", "TINYTEXT NOT NULL", "a", 770); func_mysqli_stmt_bind_datatype($link, $engine, "s", "TINYTEXT", NULL, 780); // Note: you cannot insert any blob values this way. But you can check the API at least partly this way // Extra BLOB tests are in mysqli_stmt_send_long() func_mysqli_stmt_bind_datatype($link, $engine, "b", "BLOB", "", 790); func_mysqli_stmt_bind_datatype($link, $engine, "b", "TEXT", "", 800); func_mysqli_stmt_bind_datatype($link, $engine, "b", "MEDIUMBLOB", "", 810); func_mysqli_stmt_bind_datatype($link, $engine, "b", "MEDIUMTEXT", "", 820); func_mysqli_stmt_bind_datatype($link, $engine, "b", "LONGBLOB", "", 830); func_mysqli_stmt_bind_datatype($link, $engine, "b", "LONGTEXT", "", 840); func_mysqli_stmt_bind_datatype($link, $engine, "s", "ENUM('a', 'b')", "a", 850); func_mysqli_stmt_bind_datatype($link, $engine, "s", "ENUM('a', 'b')", NULL, 860); func_mysqli_stmt_bind_datatype($link, $engine, "s", "SET('a', 'b')", "a", 870); func_mysqli_stmt_bind_datatype($link, $engine, "s", "SET('a', 'b')", NULL, 880); $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) printf("[2000] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); $id = null; $label = null; if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label))) printf("[2001] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); mysqli_stmt_execute($stmt); if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label))) printf("[2002] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); mysqli_stmt_close($stmt); include("table.inc"); if (!$stmt = mysqli_stmt_init($link)) printf("[2003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) printf("[2004] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); $id = $label = null; if (true !== ($tmp = $stmt->bind_param('is', $id, $label))) printf("[2005] Expecting boolean/true got %s/%s, [%d] %s\n", gettype($tmp), $tmp, $stmt->errno, $stmt->error); $id = 100; $label = 'z'; if (!$stmt->execute()) printf("[2006] [%d] %s\n", $stmt->errno, $stmt->error); if (!$res = mysqli_query($link, "SELECT id, label FROM test WHERE id = 100")) printf("[2007] Expecting record 100/z, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$row = mysqli_fetch_assoc($res)) printf("[2008] Expecting row, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if ($row['id'] != 100 || $row['label'] != 'z') { printf("[2009] Row seems wrong, dumping record\n"); var_dump($row); } mysqli_free_result($res); mysqli_stmt_close($stmt); mysqli_close($link); /* Check that the function alias exists. It's a deprecated function, but we have not announce the removal so far, therefore we need to check for it */ if (!is_null($tmp = @mysqli_bind_param())) printf("[021] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_stmt_bind_param(): Number of elements in type definition string doesn't match number of bind variables in %s on line %d Warning: mysqli_stmt_bind_param(): Number of elements in type definition string doesn't match number of bind variables in %s on line %d Warning: mysqli_stmt_bind_param(): Number of variables doesn't match number of parameters in prepared statement in %s on line %d Warning: mysqli_stmt_bind_param(): Number of elements in type definition string doesn't match number of bind variables in %s on line %d Warning: mysqli_stmt_bind_param(): Undefined fieldtype a (parameter 3) in %s on line %d Warning: mysqli_stmt_bind_param(): Undefined fieldtype a (parameter 4) in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_bind_param_references.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_bind_param_references.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_bind_param_references.phpt --TEST-- mysqli_stmt_bind_param() - playing with references --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; require('table.inc'); function findRow($offset, $link, $id, $label) { $sql = sprintf("SELECT id, label FROM test WHERE id = '%d' AND label = '%s'", $id, $label); if (!$res = mysqli_query($link, $sql)) { printf("[%03d + 1] %s failed, [%d] %s\n", $offset, $sql, mysqli_errno($link), mysqli_error($link)); return false; } if (!$row = mysqli_fetch_assoc($res)) { printf("[%03d + 2] fetch for %s failed, [%d] %s\n", $offset, $sql, mysqli_errno($link), mysqli_error($link)); return false; } mysqli_free_result($res); if ($row['id'] != $id) { printf("[%03d + 3] Expecting %s/%s got %s/%s\n", $offset, gettype($id), $id, gettype($row['id']), $row['id'] ); return false; } if ($row['label'] != $label) { printf("[%03d + 4] Expecting %s/%s got %s/%s\n", $offset, gettype($label), $label, gettype($row['label']), $row['label'] ); return false; } $sql = sprintf("DELETE FROM test WHERE id = '%d' AND label = '%s'", $id, $label); if (!mysqli_query($link, $sql)) { printf("[%03d + 5] %s failed, [%d] %s\n", $offset, $sql, mysqli_errno($link), mysqli_error($link)); return false; } return true; } // or we will get dups around [28] mysqli_query($link, "ALTER TABLE test DROP PRIMARY KEY"); $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) printf("[001] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); $id = 100; $label = 'v'; if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label))) printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (true !== mysqli_stmt_execute($stmt)) printf("[003] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); // no need to check the return value, will bail and make EXPECTF fail if need be findRow(4, $link, $id, $label); $id++; $label_ref = &$label; $label = 'w'; if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label_ref))) printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (true !== mysqli_stmt_execute($stmt)) printf("[006] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); findRow(7, $link, $id, $label_ref); $id++; $label_ref_ref = &$label_ref; $label = 'x'; if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label_ref_ref))) printf("[007] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (true !== mysqli_stmt_execute($stmt)) printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); findRow(9, $link, $id, $label_ref_ref); $id = 9; $label = $id; $label_num = &$label; if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label_num))) printf("[010] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (true !== mysqli_stmt_execute($stmt)) printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); findRow(12, $link, $id, $label_num); $label_num = &$id; if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label_num))) printf("[013] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (true !== mysqli_stmt_execute($stmt)) printf("[014] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); findRow(15, $link, $id, $label_num); $label = 9; $id = &$label; if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label))) printf("[015] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (true !== mysqli_stmt_execute($stmt)) printf("[016] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); findRow(17, $link, $id, $label); $base = 9; $id = &$base; $label = &$id; if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label))) printf("[018] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (true !== mysqli_stmt_execute($stmt)) printf("[019] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); findRow(20, $link, $id, $label); $id_ref = &$id; $label_ref = &$label; if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id_ref, $label_ref))) printf("[021] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (true !== mysqli_stmt_execute($stmt)) printf("[022] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); findRow(23, $link, $id_ref, $label_ref); $id_ref_ref = &$GLOBALS['id_ref']; $label_ref_ref = &$GLOBALS['label_ref_ref']; if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id_ref_ref, $label_ref_ref))) printf("[024] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (true !== mysqli_stmt_execute($stmt)) printf("[025] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); findRow(26, $link, $id_ref_ref, $label_ref_ref); $id = 102; $label = new stdClass(); $label->label = 'y'; $id_ref = &$GLOBALS['id']; $label_ref = &$label->label; if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id_ref, $label_ref))) printf("[027] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (true !== @mysqli_stmt_execute($stmt)) printf("[028] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); findRow(29, $link, $id_ref, $label_ref); $id = 103; $label_a = &$label_b; $label_b = &$label_a; $label_a = 'z'; if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label_b))) printf("[030] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (true !== mysqli_stmt_execute($stmt)) printf("[031] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); findRow(32, $link, $id, $label_b); class foo { public $foo; function foo() { $this->foo = &$this->bar; } } class bar extends foo { public $bar = 'v'; } $bar = new bar(); $id++; $label = &$GLOBALS['bar']->foo; if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label))) printf("[033] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (true !== mysqli_stmt_execute($stmt)) printf("[034] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); findRow(35, $link, $id, $label); mysqli_stmt_close($stmt); mysqli_close($link); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_bind_param_type_juggling.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_bind_param_type_juggling.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_bind_param_type_juggling.phpt --TEST-- mysqli_stmt_bind_param() - binding variable twice --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; require('table.inc'); function bind_twice($link, $engine, $sql_type1, $sql_type2, $bind_type1, $bind_type2, $bind_value1, $bind_value2, $offset) { if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) { printf("[%03d + 1] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link)); return false; } mysqli_autocommit($link, true); $sql = sprintf("CREATE TABLE test(col1 %s, col2 %s) ENGINE=%s", $sql_type1, $sql_type2, $engine); if (!mysqli_query($link, $sql)) { printf("[%03d + 2] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link)); return false; } if (!$stmt = mysqli_stmt_init($link)) { printf("[%03d + 3] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link)); return false; } if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(col1, col2) VALUES (?, ?)")) { printf("[%03d + 4] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); return false; } if (!mysqli_stmt_bind_param($stmt, $bind_type1 . $bind_type2, $bind_value1, $bind_value1)) { printf("[%03d + 5] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); return false; } if (!mysqli_stmt_execute($stmt)) { printf("[%03d + 6] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); return false; } if (!mysqli_stmt_bind_param($stmt, $bind_type1 . $bind_type2, $bind_value1, $bind_value2)) { printf("[%03d + 7] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); return false; } if (!mysqli_stmt_execute($stmt)) { printf("[%03d + 8] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); return false; } mysqli_stmt_close($stmt); if (!$res = mysqli_query($link, "SELECT col1, col2 FROM test")) { printf("[%03d + 9] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link)); return false; } if (2 !== ($tmp = mysqli_num_rows($res))) { printf("[%03d + 10] Expecting 2 rows, got %d rows [%d] %s\n", $offset, $tmp, mysqli_errno($link), mysqli_error($link)); } $row = mysqli_fetch_assoc($res); if (($row['col1'] != $bind_value1) || ($row['col2'] != $bind_value1)) { printf("[%03d + 11] Expecting col1 = %s, col2 = %s got col1 = %s, col2 = %s - [%d] %s\n", $offset, $bind_value1, $bind_value1, $row['col1'], $row['col2'], mysqli_errno($link), mysqli_error($link)); return false; } $row = mysqli_fetch_assoc($res); if (($row['col1'] != $bind_value1) || ($row['col2'] != $bind_value2)) { printf("[%03d + 12] Expecting col1 = %s, col2 = %s got col1 = %s, col2 = %s - [%d] %s\n", $offset, $bind_value1, $bind_value2, $row['col1'], $row['col2'], mysqli_errno($link), mysqli_error($link)); return false; } mysqli_free_result($res); return true; } bind_twice($link, $engine, 'CHAR(1)', 'CHAR(1)', 's', 's', 'a', 'b', 10); bind_twice($link, $engine, 'INT', 'INT', 'i', 'i', 1, 2, 20); bind_twice($link, $engine, 'FLOAT', 'FLOAT', 'd', 'd', 1.01, 1.02, 30); /* type juggling - note that int->char works */ bind_twice($link, $engine, 'CHAR(1)', 'CHAR(1)', 's', 's', 1, 2, 40); /* type juggling - note that string->integer works */ bind_twice($link, $engine, 'INT', 'INT', 'i', 'i', '1', '2', 50); /* type juggling - note that string->float works*/ bind_twice($link, $engine, 'FLOAT', 'FLOAT', 'd', 'd', '1.01', '1.02', 60); /* now, let's have two columns of different type and do type juggling */ /* what the test will do is: 1) col1 INT, col2 CHAR(1) 2) bind_param('is', 1, 1) 3) execute() 4) bind_param('is', 1, 'a') 5) execute() col1 INT, col2 INT bind_param('ii', '1', '2') --> OK (int column, string value) bind_param('ii', 1, 2) --> OK (int column, int value) col1 CHAR(1), col2 CHAR(2) bind_param('ss', 1, 2) --> OK (string column, int value) So, what about: col1 INT, COL2 CHAR(1) bind_param('is', 1, 1) ---> ?? */ bind_twice($link, $engine, 'INT', 'CHAR(1)', 'i', 's', 1, 'a', 70); mysqli_close($link); print "done!"; ?> --EXPECTF-- done! --UEXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_bind_result.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_bind_result.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_bind_result.phpt --TEST-- mysqli_stmt_bind_result() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $hint_str_or_unicode = ini_get("unicode.semantics")? "unicode":"string"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_bind_result())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_bind_result($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 1")) printf("[002a] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!is_null($tmp = @mysqli_stmt_bind_result($stmt))) printf("[002b] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); $stmt = mysqli_stmt_init($link); $id = null; $label = null; $foo = null; if (!is_null($tmp = mysqli_stmt_bind_result($stmt))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 1")) printf("[004] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (false !== ($tmp = mysqli_stmt_bind_result($stmt, $id))) printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label))) printf("[006] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label, $foo))) printf("[007] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_execute($stmt)) printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); while (mysqli_stmt_fetch($stmt)) { var_dump($id); var_dump($label); } mysqli_stmt_close($stmt); function func_mysqli_stmt_bind_result($link, $engine, $bind_type, $sql_type, $bind_value, $offset, $type_hint = null) { if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) { printf("[%04d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link)); return false; } if (!mysqli_query($link, sprintf("CREATE TABLE test(id INT, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) { // don't bail - column type might not be supported by the server, ignore this return false; } if (!$stmt = mysqli_stmt_init($link)) { printf("[%04d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link)); return false; } if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) { printf("[%04d] [%d] %s\n", $offset + 2, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); return false; } $id = null; if (!mysqli_stmt_bind_param($stmt, "i" . $bind_type, $id, $bind_value)) { printf("[%04d] [%d] %s\n", $offset + 3, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); mysqli_stmt_close($stmt); return false; } for ($id = 1; $id < 4; $id++) { if (!mysqli_stmt_execute($stmt)) { printf("[%04d] [%d] %s\n", $offset + 3 + $id, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); mysqli_stmt_close($stmt); return false; } } mysqli_stmt_close($stmt); $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test")) { printf("[%04d] [%d] %s\n", $offset + 7, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); mysqli_stmt_close($stmt); return false; } if (!mysqli_stmt_execute($stmt)) { printf("[%04d] [%d] %s\n", $offset + 8, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); mysqli_stmt_close($stmt); return false; } $result = mysqli_stmt_result_metadata($stmt); $bind_res = null; if (!mysqli_stmt_bind_result($stmt, $id, $bind_res)) { printf("[%04d] [%d] %s\n", $offset + 9, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); mysqli_stmt_close($stmt); return false; } $num = 0; $fields = mysqli_fetch_fields($result); while (mysqli_stmt_fetch($stmt)) { if (!gettype($bind_res)=="unicode") { if ($bind_res !== $bind_value && (!$type_hint || ($type_hint !== gettype($bind_res)))) { printf("[%04d] [%d] Expecting %s/'%s' [type hint = %s], got %s/'%s'\n", $offset + 10, $num, gettype($bind_value), $bind_value, $type_hint, gettype($bind_res), $bind_res); mysqli_stmt_close($stmt); return false; } } $num++; } if ($num != 3) { printf("[%04d] [%d] %s, expecting 3 results, got only %d results\n", $offset + 11, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), $num); mysqli_stmt_close($stmt); return false; } mysqli_stmt_close($stmt); return true; } function func_mysqli_stmt_bind_make_string($len) { $ret = ''; for ($i = 0; $i < $len; $i++) $ret .= chr(mt_rand(65, 90)); return $ret; } func_mysqli_stmt_bind_result($link, $engine, "i", "TINYINT", -11, 20); func_mysqli_stmt_bind_result($link, $engine, "i", "TINYINT", NULL, 40); func_mysqli_stmt_bind_result($link, $engine, "i", "TINYINT UNSIGNED", 1, 60); func_mysqli_stmt_bind_result($link, $engine, "i", "TINYINT UNSIGNED", NULL, 80); func_mysqli_stmt_bind_result($link, $engine, "i", "BOOL", 1, 100); func_mysqli_stmt_bind_result($link, $engine, "i", "BOOL", NULL, 120); func_mysqli_stmt_bind_result($link, $engine, "i", "BOOLEAN", 0, 140); func_mysqli_stmt_bind_result($link, $engine, "i", "BOOLEAN", NULL, 160); func_mysqli_stmt_bind_result($link, $engine, "i", "SMALLINT", -32768, 180); func_mysqli_stmt_bind_result($link, $engine, "i", "SMALLINT", 32767, 200); func_mysqli_stmt_bind_result($link, $engine, "i", "SMALLINT", NULL, 220); func_mysqli_stmt_bind_result($link, $engine, "i", "SMALLINT UNSIGNED", 65535, 240); func_mysqli_stmt_bind_result($link, $engine, "i", "SMALLINT UNSIGNED", NULL, 260); func_mysqli_stmt_bind_result($link, $engine, "d", "MEDIUMINT", -8388608, 280, "integer"); func_mysqli_stmt_bind_result($link, $engine, "d", "MEDIUMINT", 8388607, 300, "integer"); func_mysqli_stmt_bind_result($link, $engine, "d", "MEDIUMINT", NULL, 320); func_mysqli_stmt_bind_result($link, $engine, "d", "MEDIUMINT UNSIGNED", 16777215, 340, "integer"); func_mysqli_stmt_bind_result($link, $engine, "d", "MEDIUMINT UNSIGNED", NULL, 360); func_mysqli_stmt_bind_result($link, $engine, "i", "INTEGER", (defined("PHP_INT_MAX")) ? max(-1 * PHP_INT_MAX + 1, -2147483648) : 1, 380); func_mysqli_stmt_bind_result($link, $engine, "i", "INTEGER", -2147483647, 400, "integer"); func_mysqli_stmt_bind_result($link, $engine, "i", "INTEGER", (defined("PHP_INT_MAX")) ? min(2147483647, PHP_INT_MAX) : 1, 420); func_mysqli_stmt_bind_result($link, $engine, "i", "INTEGER", NULL, 440); func_mysqli_stmt_bind_result($link, $engine, "i", "INTEGER UNSIGNED", (defined("PHP_INT_MAX")) ? min(4294967295, 2147483647) : 1, 460); func_mysqli_stmt_bind_result($link, $engine, "i", "INTEGER UNSIGNED", 4294967295, 480, (defined("PHP_INT_MAX") && (4294967295 > PHP_INT_MAX)) ? "string" : null); func_mysqli_stmt_bind_result($link, $engine, "i", "INTEGER UNSIGNED", NULL, 500); /* test is broken too: we bind "integer" but value is a float func_mysqli_stmt_bind_result($link, $engine, "i", "BIGINT", -9223372036854775808, 520); func_mysqli_stmt_bind_result($link, $engine, "i", "BIGINT UNSIGNED", 18446744073709551615, 560); */ func_mysqli_stmt_bind_result($link, $engine, "i", "BIGINT", NULL, 540); func_mysqli_stmt_bind_result($link, $engine, "i", "BIGINT UNSIGNED", NULL, 580); func_mysqli_stmt_bind_result($link, $engine, "i", "BIGINT", -1, 1780); func_mysqli_stmt_bind_result($link, $engine, "i", "BIGINT UNSIGNED", 1, 1800); func_mysqli_stmt_bind_result($link, $engine, "i", "BIGINT", -1 * PHP_INT_MAX + 1, 1820); func_mysqli_stmt_bind_result($link, $engine, "i", "BIGINT UNSIGNED", PHP_INT_MAX, 1840); func_mysqli_stmt_bind_result($link, $engine, "s", "BIGINT UNSIGNED", "18446744073709551615", 1860); func_mysqli_stmt_bind_result($link, $engine, "s", "BIGINT", "-9223372036854775808", 1880); func_mysqli_stmt_bind_result($link, $engine, "d", "FLOAT", -9223372036854775808 - 1.1, 600); func_mysqli_stmt_bind_result($link, $engine, "d", "FLOAT", NULL, 620); func_mysqli_stmt_bind_result($link, $engine, "d", "FLOAT UNSIGNED", 18446744073709551615 + 1.1, 640); func_mysqli_stmt_bind_result($link, $engine, "d", "FLOAT UNSIGNED ", NULL, 660); // Yes, we need the temporary variable. The PHP casting will fouls us otherwise. $tmp = strval('-99999999.99'); func_mysqli_stmt_bind_result($link, $engine, "d", "DOUBLE(10,2)", $tmp, 680, "string"); func_mysqli_stmt_bind_result($link, $engine, "d", "DOUBLE(10,2)", NULL, 700); $tmp = strval('99999999.99'); func_mysqli_stmt_bind_result($link, $engine, "d", "DOUBLE(10,2) UNSIGNED", $tmp , 720, "string"); func_mysqli_stmt_bind_result($link, $engine, "d", "DOUBLE(10,2) UNSIGNED", NULL, 740); $tmp = strval('-99999999.99'); func_mysqli_stmt_bind_result($link, $engine, "d", "DECIMAL(10,2)", $tmp, 760, "string"); func_mysqli_stmt_bind_result($link, $engine, "d", "DECIMAL(10,2)", NULL, 780); $tmp = strval('99999999.99'); func_mysqli_stmt_bind_result($link, $engine, "d", "DECIMAL(10,2)", $tmp, 800, "string"); func_mysqli_stmt_bind_result($link, $engine, "d", "DECIMAL(10,2)", NULL, 820); // don't care about date() strict TZ warnings... func_mysqli_stmt_bind_result($link, $engine, "s", "DATE", @date('Y-m-d'), 840); func_mysqli_stmt_bind_result($link, $engine, "s", "DATE NOT NULL", @date('Y-m-d'), 860); func_mysqli_stmt_bind_result($link, $engine, "s", "DATE", NULL, 880); func_mysqli_stmt_bind_result($link, $engine, "s", "DATETIME", @date('Y-m-d H:i:s'), 900); func_mysqli_stmt_bind_result($link, $engine, "s", "DATETIME NOT NULL", @date('Y-m-d H:i:s'), 920); func_mysqli_stmt_bind_result($link, $engine, "s", "DATETIME", NULL, 940); func_mysqli_stmt_bind_result($link, $engine, "s", "TIMESTAMP", @date('Y-m-d H:i:s'), 960); func_mysqli_stmt_bind_result($link, $engine, "s", "TIME", @date('H:i:s'), 980); func_mysqli_stmt_bind_result($link, $engine, "s", "TIME NOT NULL", @date('H:i:s'), 1000); func_mysqli_stmt_bind_result($link, $engine, "s", "TIME", NULL, 1020); $tmp = intval(@date('Y')); func_mysqli_stmt_bind_result($link, $engine, "s", "YEAR", $tmp, 1040, "integer"); func_mysqli_stmt_bind_result($link, $engine, "s", "YEAR NOT NULL", $tmp, 1060, "integer"); func_mysqli_stmt_bind_result($link, $engine, "s", "YEAR", NULL, 1080); $string255 = func_mysqli_stmt_bind_make_string(255); func_mysqli_stmt_bind_result($link, $engine, "s", "CHAR(1)", "a", 1110, $hint_str_or_unicode); func_mysqli_stmt_bind_result($link, $engine, "s", "CHAR(255)", $string255, 1120, $hint_str_or_unicode); func_mysqli_stmt_bind_result($link, $engine, "s", "CHAR(1) NOT NULL", "a", 1140, $hint_str_or_unicode); func_mysqli_stmt_bind_result($link, $engine, "s", "CHAR(1)", NULL, 1160); $string65k = func_mysqli_stmt_bind_make_string(65535); func_mysqli_stmt_bind_result($link, $engine, "s", "VARCHAR(1)", "a", 1180, $hint_str_or_unicode); func_mysqli_stmt_bind_result($link, $engine, "s", "VARCHAR(255)", $string255, 1200, $hint_str_or_unicode); func_mysqli_stmt_bind_result($link, $engine, "s", "VARCHAR(65635)", $string65k, 1220, $hint_str_or_unicode); func_mysqli_stmt_bind_result($link, $engine, "s", "VARCHAR(1) NOT NULL", "a", 1240, $hint_str_or_unicode); func_mysqli_stmt_bind_result($link, $engine, "s", "VARCHAR(1)", NULL, 1260); func_mysqli_stmt_bind_result($link, $engine, "s", "BINARY(1)", "a", 1280); func_mysqli_stmt_bind_result($link, $engine, "s", "BINARY(1)", chr(0), 1300); func_mysqli_stmt_bind_result($link, $engine, "s", "BINARY(1) NOT NULL", "b", 1320); func_mysqli_stmt_bind_result($link, $engine, "s", "BINARY(1)", NULL, 1340); func_mysqli_stmt_bind_result($link, $engine, "s", "VARBINARY(1)", "a", 1360); func_mysqli_stmt_bind_result($link, $engine, "s", "VARBINARY(1)", chr(0), 1380); func_mysqli_stmt_bind_result($link, $engine, "s", "VARBINARY(1) NOT NULL", "b", 1400); func_mysqli_stmt_bind_result($link, $engine, "s", "VARBINARY(1)", NULL, 1420); func_mysqli_stmt_bind_result($link, $engine, "s", "TINYBLOB", "a", 1440); func_mysqli_stmt_bind_result($link, $engine, "s", "TINYBLOB", chr(0), 1460); func_mysqli_stmt_bind_result($link, $engine, "s", "TINYBLOB NOT NULL", "b", 1480); func_mysqli_stmt_bind_result($link, $engine, "s", "TINYBLOB", NULL, 1500); func_mysqli_stmt_bind_result($link, $engine, "s", "TINYTEXT", "a", 1520, $hint_str_or_unicode); func_mysqli_stmt_bind_result($link, $engine, "s", "TINYTEXT NOT NULL", "a", 1540, $hint_str_or_unicode); func_mysqli_stmt_bind_result($link, $engine, "s", "TINYTEXT", NULL, 1560, $hint_str_or_unicode); // Note: you cannot insert any blob values this way. But you can check the API at least partly this way // Extra BLOB tests are in mysqli_stmt_send_long() func_mysqli_stmt_bind_result($link, $engine, "b", "BLOB", b"", 1580); func_mysqli_stmt_bind_result($link, $engine, "b", "TEXT", "", 1600, $hint_str_or_unicode); func_mysqli_stmt_bind_result($link, $engine, "b", "MEDIUMBLOB", b"", 1620); func_mysqli_stmt_bind_result($link, $engine, "b", "MEDIUMTEXT", "", 1640, $hint_str_or_unicode); /* Is this one related? http://bugs.php.net/bug.php?id=35759 */ func_mysqli_stmt_bind_result($link, $engine, "b", "LONGBLOB", "", 1660); func_mysqli_stmt_bind_result($link, $engine, "b", "LONGTEXT", "", 1680, $hint_str_or_unicode); func_mysqli_stmt_bind_result($link, $engine, "s", "ENUM('a', 'b')", "a", 1700, $hint_str_or_unicode); func_mysqli_stmt_bind_result($link, $engine, "s", "ENUM('a', 'b')", NULL, 1720, $hint_str_or_unicode); func_mysqli_stmt_bind_result($link, $engine, "s", "SET('a', 'b')", "a", 1740, $hint_str_or_unicode); func_mysqli_stmt_bind_result($link, $engine, "s", "SET('a', 'b')", NULL, 1760, $hint_str_or_unicode); /* Check that the function alias exists. It's a deprecated function, but we have not announce the removal so far, therefore we need to check for it */ if (!is_null($tmp = @mysqli_bind_result())) printf("[3000] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); print "done!"; ?> --EXPECTF-- Warning: mysqli_stmt_bind_result(): invalid object or resource mysqli_stmt in %s on line %d Warning: mysqli_stmt_bind_result(): Number of bind variables doesn't match number of fields in prepared statement in %s on line %d Warning: mysqli_stmt_bind_result(): Number of bind variables doesn't match number of fields in prepared statement in %s on line %d int(1) %s(1) "a" done! --UEXPECTF-- Warning: mysqli_stmt_bind_result(): invalid object or resource mysqli_stmt in %s on line %d Warning: mysqli_stmt_bind_result(): Number of bind variables doesn't match number of fields in prepared statement in %s on line %d Warning: mysqli_stmt_bind_result(): Number of bind variables doesn't match number of fields in prepared statement in %s on line %d int(1) unicode(1) "a" done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_bind_result_bit.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_bind_result_bit.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_bind_result_bit.phpt --TEST-- mysqli_stmt_bind_result() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; function dec32bin($dec, $bits) { $maxval = pow(2, $bits); $bin = ''; for ($bitval = $maxval; $bitval >= 1; $bitval = $bitval / 2) { if (($dec / $bitval) >= 1) { $bin .= '1'; $dec -= $bitval; } else { $bin .= '0'; } } return $bin; } if (!$link_ins = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (!$link_sel = mysqli_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); for ($bits = 1; $bits <= 46; $bits++) { if (1 == $bits) $max_value = 1; else $max_value = pow(2, $bits) - 1; if (!mysqli_query($link_ins, "DROP TABLE IF EXISTS test")) { printf("[003 - %d] [%d] %s\n", $bits, mysqli_errno($link_ins), mysqli_error($link_ins)); } if (!mysqli_query($link_ins, sprintf("CREATE TABLE test(id BIGINT, bit_value BIT(%d) NOT NULL, bit_null BIT(%d) DEFAULT NULL) ENGINE = %s", $bits, $bits, $engine))) { // don't bail - column type might not be supported by the server, ignore this continue; } if (!$stmt_ins = mysqli_stmt_init($link_ins)) { printf("[004 - %d] [%d] %s\n", $bits, mysqli_errno($link_ins), mysqli_error($link_ins)); continue; } if (!mysqli_stmt_prepare($stmt_ins, "INSERT INTO test(id, bit_value) VALUES (?, ?)")) { printf("[005 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt_ins), mysqli_stmt_error($stmt_ins)); mysqli_stmt_close($stmt_ins); continue; } if (!($stmt_sel = mysqli_stmt_init($link_sel))) { printf("[006 - %d] [%d] %s\n", $bits, mysqli_errno($link_sel), mysqli_error($link_sel)); mysqli_stmt_close($stmt_ins); continue; } $tests = 0; $rand_max = mt_getrandmax(); while ($tests < 10) { $tests++; if (1 == $tests) $value = 0; else if (2 == $tests) $value = $max_value; else { if ($max_value > $rand_max) { $max_loops = floor($max_value/$rand_max); $num_loops = mt_rand(1, $max_loops); $value = 0; for ($i = 0; $i < $num_loops; $i++) $value += mt_rand(0, $rand_max); } else { $value = mt_rand(0, $max_value); } } $bin = ($bits < 32) ? decbin($value) : dec32bin($value, $bits); for ($i = 0; ($i < strlen($bin)) && ($bin[$i] == '0'); $i++) ; $bin2 = substr($bin, $i, strlen($bin)); if (!mysqli_stmt_bind_param($stmt_ins, "dd", $value, $value)) { printf("[007 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt_ins), mysqli_stmt_error($stmt_ins)); mysqli_stmt_close($stmt_ins); continue; } if (!mysqli_stmt_execute($stmt_ins)) { printf("[008 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt_ins), mysqli_stmt_error($stmt_ins)); break; } $sql = sprintf("SELECT id, BIN(bit_value) AS _bin, bit_value, bit_value + 0 AS _bit_value0, bit_null FROM test WHERE id = %d", $value); if ((!mysqli_stmt_prepare($stmt_sel, $sql)) || (!mysqli_stmt_execute($stmt_sel))) { printf("[009 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt_sel), mysqli_stmt_error($stmt_sel)); break; } $row = array('id' => -1, '_bin' => - 1, 'bit_value' => -1, '_bit_value0' => -1, 'bit_null' => -1); if (!mysqli_stmt_bind_result($stmt_sel, $row['id'], $row['_bin'], $row['bit_value'], $row['_bit_value0'], $row['bit_null'])) { printf("[010 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt_sel), mysqli_stmt_error($stmt_sel)); break; } if (!mysqli_stmt_fetch($stmt_sel)) { printf("[011 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt_sel), mysqli_stmt_error($stmt_sel)); break; } if (($value != $row['id']) || (($bin != $row['_bin']) && ($bin2 != $row['_bin']))) { debug_zval_dump($row); printf("[012 - %d] Insert of %s in BIT(%d) column might have failed. id = %s, bin = %s (%s/%s)\n", $bits, $value, $bits, $row['id'], $row['_bin'], $bin, $bin2); break; } if ($value != $row['bit_value']) { debug_zval_dump($row); printf("[013 - %d] Expecting %s got %s\n", $bits, $value, $row['bit_value']); break; } if (null !== $row['bit_null']) { debug_zval_dump($row); printf("[014 - %d] Expecting null got %s/%s\n", $bits, gettype($row['bit_value']), $row['bit_value']); break; } } mysqli_stmt_close($stmt_ins); mysqli_stmt_close($stmt_sel); } mysqli_close($link_ins); mysqli_close($link_sel); print "done!"; ?> --EXPECTF-- done! --UEXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_bind_result_references.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_bind_result_references.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_bind_result_references.phpt --TEST-- mysqli_stmt_bind_result() - playing with references --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; require('table.inc'); $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 1")) printf("[001] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 1")) printf("[001] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); print "plain vanilla...\n"; unset($id); unset($label); $id = $label = null; if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label))) printf("[002] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt)) printf("[003] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); var_dump($id); var_dump($label); print "reference, one level...\n"; unset($id); unset($id_ref); unset($label); unset($label_ref); $id = null; $id_ref = &$id; $label = null; $label_ref = &$label; if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id_ref, $label_ref))) printf("[004] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt)) printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); var_dump($id_ref); var_dump($id); var_dump($label_ref); var_dump($label); print "reference, two levels...\n"; unset($id); unset($id_ref); unset($id_ref_ref); unset($label); unset($label_ref); unset($label_ref_ref); $id = null; $id_ref = &$id; $id_ref_ref = &$id_ref; $label = null; $label_ref = &$label; $label_ref_ref = &$label_ref; if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id_ref_ref, $label_ref_ref))) printf("[006] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt)) printf("[007] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); var_dump($id_ref_ref); var_dump($id_ref); var_dump($id); var_dump($label_ref_ref); var_dump($label_ref); var_dump($label); print "reference, \$GLOBALS...\n"; unset($id); unset($id_ref); unset($label); unset($label_ref); $id = 100; $id_ref = &$GLOBALS['id']; $label = null; $label_ref = &$GLOBALS['label']; if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id_ref, $label_ref))) printf("[008] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt)) printf("[009] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); var_dump($id_ref); var_dump($id); var_dump($label_ref); var_dump($label); print "reference, same target...\n"; $id = null; $label = &$id; if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label))) printf("[010] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt)) printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); var_dump($id); var_dump($label); print "reference, simple object...\n"; unset($obj); $obj = new stdClass(); $obj->id = null; $obj->label = null; if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $obj->id, $obj->label))) printf("[012] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt)) printf("[013] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); var_dump($obj->id); var_dump($obj->label); print "reference, simple object w reference...\n"; unset($id); unset($label); unset($obj); $obj = new stdClass(); $obj->id = null; $obj->label = null; $id = &$obj->id; $label = &$obj->label; if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label))) printf("[012] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt)) printf("[013] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); var_dump($obj->id); var_dump($obj->label); print "reference, simple object w reference, change after bind...\n"; unset($id); unset($label); unset($obj); $obj = new stdClass(); $obj->id = null; $obj->label = null; $id = &$obj->id; $label = &$obj->label; if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label))) printf("[012] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); $label = &$obj->id; $id = null; if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt)) printf("[013] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); var_dump($obj->id); var_dump($id); var_dump($obj->label); var_dump($label); print "reference, one level, change after bind...\n"; unset($id); unset($label); unset($id_ref); unset($label_ref); $id = null; $id_ref = &$id; $label = null; $label_ref = &$label; if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id_ref, $label_ref))) printf("[014] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); $id_ref = 1; $label_ref = 1; if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt)) printf("[015] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); var_dump($id_ref); var_dump($id); var_dump($label_ref); var_dump($label); print "reference, circle...\n"; unset($id); unset($label_a); unset($label_b); $id = null; $label_a = &$label_b; $label_b = &$label_a; if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label_a))) printf("[016] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt)) printf("[017] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); var_dump($id); var_dump($label_a); var_dump($label_b); print "reference, object, forward declaration...\n"; unset($bar); unset($id); unset($label_ref); class foo { public $foo; public function foo() { $this->foo = &$this->bar; } } class bar extends foo { public $bar = null; } $bar = new bar(); $id = null; $label_ref = &$bar->bar; if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label_ref))) printf("[018] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt)) printf("[019] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); var_dump($id); var_dump($bar); var_dump($label_ref); print "references, object, private...\n"; unset($bar); unset($id); unset($label); class mega_bar extends bar { private $id; public $id_ref; public function mega_bar() { $this->foo(); $this->id_ref = &$this->id; } } $bar = new mega_bar(); $id = &$bar->id_ref; $label = &$bar->foo; if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label))) printf("[020] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt)) printf("[021] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); var_dump($id); var_dump($label); var_dump($bar); mysqli_stmt_close($stmt); mysqli_close($link); print "done!"; ?> --EXPECTF-- plain vanilla... int(1) string(1) "a" reference, one level... int(1) int(1) string(1) "a" string(1) "a" reference, two levels... int(1) int(1) int(1) string(1) "a" string(1) "a" string(1) "a" reference, $GLOBALS... int(1) int(1) string(1) "a" string(1) "a" reference, same target... string(1) "a" string(1) "a" reference, simple object... int(1) string(1) "a" reference, simple object w reference... int(1) string(1) "a" reference, simple object w reference, change after bind... int(1) int(1) string(1) "a" int(1) reference, one level, change after bind... int(1) int(1) string(1) "a" string(1) "a" reference, circle... int(1) string(1) "a" string(1) "a" reference, object, forward declaration... int(1) object(bar)#%d (2) { ["bar"]=> &string(1) "a" ["foo"]=> &string(1) "a" } string(1) "a" references, object, private... int(1) string(1) "a" object(mega_bar)#5 (4) { [%s]=> &int(1) ["id_ref"]=> &int(1) ["bar"]=> &string(1) "a" ["foo"]=> &string(1) "a" } done! --UEXPECTF-- plain vanilla... int(1) unicode(1) "a" reference, one level... int(1) int(1) unicode(1) "a" unicode(1) "a" reference, two levels... int(1) int(1) int(1) unicode(1) "a" unicode(1) "a" unicode(1) "a" reference, $GLOBALS... int(1) int(1) unicode(1) "a" unicode(1) "a" reference, same target... unicode(1) "a" unicode(1) "a" reference, simple object... int(1) unicode(1) "a" reference, simple object w reference... int(1) unicode(1) "a" reference, simple object w reference, change after bind... int(1) int(1) unicode(1) "a" int(1) reference, one level, change after bind... int(1) int(1) unicode(1) "a" unicode(1) "a" reference, circle... int(1) unicode(1) "a" unicode(1) "a" reference, object, forward declaration... int(1) object(bar)#%d (2) { [u"bar"]=> &unicode(1) "a" [u"foo"]=> &unicode(1) "a" } unicode(1) "a" references, object, private... int(1) unicode(1) "a" object(mega_bar)#5 (4) { [u"id":u"mega_bar":private]=> &int(1) [u"id_ref"]=> &int(1) [u"bar"]=> &unicode(1) "a" [u"foo"]=> &unicode(1) "a" } done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_close.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_close.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_close.phpt --TEST-- mysqli_stmt_close() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_close())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_close($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$stmt = mysqli_stmt_init($link)) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); // Yes, amazing, eh? AFAIK a work around of a constructor bug... if (!is_null($tmp = mysqli_stmt_close($stmt))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test")) printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (true !== ($tmp = mysqli_stmt_close($stmt))) printf("[006] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = mysqli_stmt_close($stmt))) printf("[007] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$stmt = mysqli_stmt_init($link)) printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) printf("[009] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); $id = $label = null; if (!mysqli_stmt_bind_param($stmt, "is", $id, $label)) printf("[010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); $id = 100; $label = 'z'; if (!mysqli_stmt_execute($stmt)) printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); mysqli_kill($link, mysqli_thread_id($link)); if (true !== ($tmp = mysqli_stmt_close($stmt))) printf("[012] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); require('table.inc'); if (!$stmt = mysqli_stmt_init($link)) printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test")) printf("[014] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); $id = $label = null; if (!mysqli_stmt_bind_result($stmt, $id, $label)) printf("[015] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt)) printf("[016] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); mysqli_kill($link, mysqli_thread_id($link)); if (true !== ($tmp = mysqli_stmt_close($stmt))) printf("[017] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_stmt_close(): invalid object or resource mysqli_stmt in %s on line %d Warning: mysqli_stmt_close(): Couldn't fetch mysqli_stmt in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_data_seek.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_data_seek.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_data_seek.phpt --TEST-- mysqli_stmt_data_seek() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_data_seek())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_data_seek($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$stmt = mysqli_stmt_init($link)) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_null($tmp = mysqli_stmt_data_seek($stmt, 1))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, "SELECT id FROM test ORDER BY id")) printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (true !== ($tmp = mysqli_stmt_execute($stmt))) printf("[006] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); $id = null; if (!mysqli_stmt_bind_result($stmt, $id)) printf("[007] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!mysqli_stmt_store_result($stmt)) printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!is_null($tmp = mysqli_stmt_data_seek($stmt, 2))) printf("[009] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_fetch($stmt)) printf("[010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); var_dump($id); if (!is_null($tmp = mysqli_stmt_data_seek($stmt, 0))) printf("[011] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_fetch($stmt)) printf("[012] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); var_dump($id); if (!is_null($tmp = mysqli_stmt_data_seek($stmt, mysqli_stmt_num_rows($stmt) + 100))) printf("[013] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (mysqli_stmt_fetch($stmt)) printf("[014] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); var_dump($id); if (false !== ($tmp = mysqli_stmt_data_seek($stmt, -1))) printf("[015] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (mysqli_stmt_fetch($stmt)) printf("[016] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); var_dump($id); mysqli_stmt_close($stmt); if (NULL !== ($tmp = mysqli_stmt_data_seek($stmt, 0))) printf("[017] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); print "done!"; ?> --EXPECTF-- Warning: mysqli_stmt_data_seek(): invalid object or resource mysqli_stmt in %s on line %d int(3) int(1) int(1) Warning: mysqli_stmt_data_seek(): Offset must be positive in %s on line %d int(1) Warning: mysqli_stmt_data_seek(): Couldn't fetch mysqli_stmt in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_errno.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_errno.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_errno.phpt --TEST-- mysqli_stmt_errno() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_errno())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_errno($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$stmt = mysqli_stmt_init($link)) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); // properly initialized? if (0 !== ($tmp = mysqli_stmt_errno($stmt))) printf("[004] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); if (mysqli_stmt_prepare($stmt, "SELECT i_do_not_exist_believe_me FROM test ORDER BY id")) printf("[005] Statement should have failed!\n"); // set after error server? if (0 === ($tmp = mysqli_stmt_errno($stmt))) printf("[006] Expecting int/any non zero, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, "SELECT id FROM test ORDER BY id")) printf("[007] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); // reset after error & success if (0 != ($tmp = mysqli_stmt_errno($stmt))) printf("[008] Expecting zero, got %s/%s\n", gettype($tmp), $tmp); mysqli_kill($link, mysqli_thread_id($link)); if (true === ($tmp = mysqli_stmt_execute($stmt))) printf("[009] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); // set after client error if (0 === ($tmp = mysqli_stmt_errno($stmt))) printf("[010] Execting int/any non zero, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); if (NULL !== ($tmp = mysqli_stmt_errno($stmt))) printf("[011] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); print "done!"; ?> --EXPECTF-- Warning: mysqli_stmt_errno(): Couldn't fetch mysqli_stmt in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_error.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_error.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_error.phpt --TEST-- mysqli_stmt_error() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_error())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_error($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$stmt = mysqli_stmt_init($link)) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); // properly initialized? if ('' !== ($tmp = mysqli_stmt_error($stmt))) printf("[004] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); if (mysqli_stmt_prepare($stmt, "SELECT i_do_not_exist_believe_me FROM test ORDER BY id")) printf("[005] Statement should have failed!\n"); // set after error server? if ('' === ($tmp = mysqli_stmt_error($stmt))) printf("[006] Expecting string/any non empty, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, "SELECT id FROM test ORDER BY id")) printf("[007] [%d] %s\n", mysqli_stmt_error($stmt), mysqli_stmt_error($stmt)); // reset after error & success if ('' !== ($tmp = mysqli_stmt_error($stmt))) printf("[008] Expecting empty string, got %s/%s\n", gettype($tmp), $tmp); mysqli_kill($link, mysqli_thread_id($link)); if (true === ($tmp = mysqli_stmt_execute($stmt))) printf("[009] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); // set after client error if ('' === ($tmp = mysqli_stmt_error($stmt))) printf("[010] Execting string/any non empty, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); if (NULL !== ($tmp = mysqli_stmt_error($stmt))) printf("[011] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); print "done!"; ?> --EXPECTF-- Warning: mysqli_stmt_error(): Couldn't fetch mysqli_stmt in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_execute.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_execute.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_execute.phpt --TEST-- mysqli_stmt_execute() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_execute())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_execute($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$stmt = mysqli_stmt_init($link)) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); // stmt object status test if (NULL !== ($tmp = mysqli_stmt_execute($stmt))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (mysqli_stmt_prepare($stmt, "SELECT i_do_not_exist_believe_me FROM test ORDER BY id")) printf("[005] Statement should have failed!\n"); // stmt object status test if (NULL !== ($tmp = mysqli_stmt_execute($stmt))) printf("[006] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, "SELECT id FROM test ORDER BY id LIMIT 1")) printf("[007] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (true !== ($tmp = mysqli_stmt_execute($stmt))) printf("[008] Expecting boolean/true, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) printf("[009] [%d] %s\n", mysqli_stmt_execute($stmt), mysqli_stmt_execute($stmt)); // no input variables bound if (false !== ($tmp = mysqli_stmt_execute($stmt))) printf("[010] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); $id = 100; $label = "z"; if (!mysqli_stmt_bind_param($stmt, "is", $id, $label)) printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (true !== ($tmp = mysqli_stmt_execute($stmt))) printf("[012] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); mysqli_kill($link, mysqli_thread_id($link)); if (false !== ($tmp = mysqli_stmt_execute($stmt))) printf("[014] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); if (NULL !== ($tmp = mysqli_stmt_execute($stmt))) printf("[015] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); print "done!"; ?> --EXPECTF-- Warning: mysqli_stmt_execute(): invalid object or resource mysqli_stmt in %s on line %d Warning: mysqli_stmt_execute(): invalid object or resource mysqli_stmt in %s on line %d Warning: mysqli_stmt_execute(): Couldn't fetch mysqli_stmt in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_fetch.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_fetch.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_fetch.phpt --TEST-- mysqli_stmt_fetch() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php /* NOTE: no datatype tests here! This is done by mysqli_stmt_bind_result.phpt already. Restrict this test case to the basics. */ include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_fetch())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_fetch($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$stmt = mysqli_stmt_init($link)) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); // stmt object status test if (NULL !== ($tmp = mysqli_stmt_fetch($stmt))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 2")) printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); // FIXME - different versions return different values ?! if ((NULL !== ($tmp = mysqli_stmt_fetch($stmt))) && (false !== $tmp)) printf("[006] Expecting NULL or boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_execute($stmt)) printf("[007] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (true !== ($tmp = mysqli_stmt_fetch($stmt))) printf("[008] NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); if (!$stmt = mysqli_stmt_init($link)) printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 2")) printf("[010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!mysqli_stmt_execute($stmt)) printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); $id = NULL; $label = NULL; if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label))) printf("[012] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = mysqli_stmt_fetch($stmt))) printf("[013] Expecting boolean/true, got %s/%s, [%d] %s\n", gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!mysqli_kill($link, mysqli_thread_id($link))) printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (true !== ($tmp = mysqli_stmt_fetch($stmt))) printf("[015] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); if (NULL !== ($tmp = mysqli_stmt_fetch($stmt))) printf("[016] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); /* Check that the function alias exists. It's a deprecated function, but we have not announce the removal so far, therefore we need to check for it */ if (!is_null($tmp = @mysqli_fetch())) printf("[017] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_stmt_fetch(): invalid object or resource mysqli_stmt in %s on line %d [014] [%d] Commands out of sync; you can't run this command now Warning: mysqli_stmt_fetch(): Couldn't fetch mysqli_stmt in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_fetch_bit.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_fetch_bit.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_fetch_bit.phpt --TEST-- Fetching BIT column values using the PS API --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('connect.inc'); require_once('table.inc'); if (mysqli_get_server_version($link) < 50003) // b'001' syntax not supported before 5.0.3 die("skip Syntax used for test not supported with MySQL Server before 5.0.3"); if (!$IS_MYSQLND && (mysqli_get_client_version() < 50003)) // better don't trust libmysql before 5.0.3 die("skip Syntax used for test not supported with MySQL Server before 5.0.3"); ?> --FILE-- <?php require('connect.inc'); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); for ($bits = 1; $bits < 64; $bits++) { $max_value = pow(2, $bits) - 1; $tests = 0; if (!mysqli_query($link, "DROP TABLE IF EXISTS test") || !mysqli_query($link, $sql = sprintf('CREATE TABLE test(id INT, label BIT(%d)) ENGINE="%s"', $bits, $engine))) printf("[002 - %d] [%d] %s\n",$bits, mysqli_errno($link), mysqli_error($link)); if (!$stmt = mysqli_stmt_init($link)) printf("[003 - %d] [%d] %s\n", $bits, mysqli_errno($link), mysqli_error($link)); while ($tests < min($max_value, 20)) { $tests++; $value = mt_rand(0, $max_value); $sql = sprintf("INSERT INTO test(id, label) VALUES (%d, b'%s')", $value, decbin($value)); if (!mysqli_stmt_prepare($stmt, $sql) || !mysqli_stmt_execute($stmt)) printf("[004 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); $id = $_label0 = $label = null; $sql = sprintf("SELECT id, label + 0 AS _label0, label FROM test WHERE id = %d", $value); if (!mysqli_stmt_prepare($stmt, $sql) || !mysqli_stmt_execute($stmt) || !mysqli_stmt_bind_result($stmt, $id, $_label0, $label)) printf("[005 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!mysqli_stmt_fetch($stmt)) printf("[006 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (($id !== $_label0) || ($value !== $_label0)) { printf("[007 - %d] Insert of %d in BIT(%d) column might have failed. MySQL reports odd values, id = %s, _label0 = %s, label = %s.\n", $bits, $value, $bits, $id, $_label0, $label); } if ($value != $label) { printf("[008 - %d] Wrong values, (original) value = %s, id = %s, label + 0 AS label0 = %s, label = %s\n", $bits, $value, $id, $_label0, $label); } } mysqli_stmt_close($stmt); } mysqli_close($link); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_fetch_fields_win32_unicode.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_fetch_fields_win32_unicode.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_fetch_fields_win32_unicode.phpt --TEST-- mysqli_stmt_fetch_fields() unicode, win32 --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; require('table.inc'); $bind_res = $id = null; if (!($stmt = mysqli_stmt_init($link)) || !mysqli_stmt_prepare($stmt, "SELECT id, label FROM test") || !mysqli_stmt_execute($stmt) || !($result = mysqli_stmt_result_metadata($stmt)) || !mysqli_stmt_bind_result($stmt, $id, $bind_res) || !($fields = mysqli_fetch_fields($result))) { printf("FAIL 1\n"); } while (mysqli_stmt_fetch($stmt)) { ; } mysqli_free_result($result); mysqli_stmt_close($stmt); if (!($stmt = mysqli_stmt_init($link)) || !mysqli_stmt_prepare($stmt, "SELECT id, label FROM test") || !mysqli_stmt_execute($stmt) || !($result = mysqli_stmt_result_metadata($stmt)) || !mysqli_stmt_bind_result($stmt, $id, $bind_res)) { printf("FAIL 2\n"); } print "OK: 1\n"; if (!($fields = mysqli_fetch_fields($result))) printf("Aua 3\n"); print "OK: 2\n"; while (mysqli_stmt_fetch($stmt)) { ; } mysqli_free_result($result); mysqli_stmt_close($stmt); mysqli_close($link); print "done!"; ?> --EXPECTF-- OK: 1 OK: 2 done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_field_count.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_field_count.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_field_count.phpt --TEST-- mysqli_stmt_field_counts() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_field_count())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_field_count($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); $stmt = mysqli_stmt_init($link); if (!is_null($tmp = mysqli_stmt_field_count($stmt))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (mysqli_stmt_prepare($stmt, '')) printf("[004] Prepare should fail for an empty statement\n"); if (!is_null($tmp = mysqli_stmt_field_count($stmt))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, 'SELECT 1')) printf("[006] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (1 !== ($tmp = mysqli_stmt_field_count($stmt))) printf("[007] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, 'SELECT 1, 2')) printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (2 !== ($tmp = mysqli_stmt_field_count($stmt))) printf("[009] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test')) printf("[010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (2 !== ($tmp = mysqli_stmt_field_count($stmt))) printf("[011] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, 'SELECT label FROM test') || !mysqli_stmt_execute($stmt)) printf("[012] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (1 !== ($tmp = mysqli_stmt_field_count($stmt))) printf("[013] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); $label = null; if (mysqli_stmt_bind_param($stmt, "s", $label)) printf("[014] expected error - got ok\n"); while (mysqli_stmt_fetch($stmt)) if (1 !== ($tmp = mysqli_stmt_field_count($stmt))) printf("[015] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, 'INSERT INTO test(id) VALUES (100)')) printf("[016] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (0 !== ($tmp = mysqli_stmt_field_count($stmt))) printf("[017] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, 'UPDATE test SET label = "z" WHERE id = 1') || !mysqli_stmt_execute($stmt)) printf("[018] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (0 !== ($tmp = mysqli_stmt_field_count($stmt))) printf("[019] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); if (mysqli_stmt_prepare($stmt, 'SELECT id FROM test')) printf("[020] Prepare should fail, statement has been closed\n"); if (!is_null($tmp = mysqli_stmt_field_count($stmt))) printf("[011] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); print "done!"; ?> --EXPECTF-- Warning: mysqli_stmt_field_count(): invalid object or resource mysqli_stmt in %s on line %d Warning: mysqli_stmt_field_count(): invalid object or resource mysqli_stmt in %s on line %d Warning: mysqli_stmt_prepare(): Couldn't fetch mysqli_stmt in %s on line %d Warning: mysqli_stmt_field_count(): Couldn't fetch mysqli_stmt in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_free_result.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_free_result.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_free_result.phpt --TEST-- mysqli_stmt_free_result() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php /* NOTE: no datatype tests here! This is done by mysqli_stmt_bind_result.phpt already. Restrict this test case to the basics. */ include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_free_result())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_free_result($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$stmt = mysqli_stmt_init($link)) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); // stmt object status test if (NULL !== ($tmp = mysqli_stmt_free_result($stmt))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id")) printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (NULL !== ($tmp = mysqli_stmt_free_result($stmt))) printf("[006] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_execute($stmt)) printf("[007] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (NULL !== ($tmp = mysqli_stmt_free_result($stmt))) printf("[008] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysqli_stmt_store_result($stmt))) printf("[009] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); if (!$stmt = mysqli_stmt_init($link)) printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id")) printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!mysqli_stmt_execute($stmt)) printf("[012] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (true !== ($tmp = mysqli_stmt_store_result($stmt))) printf("[013] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = mysqli_stmt_free_result($stmt))) printf("[014] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); if (NULL !== ($tmp = mysqli_stmt_free_result($stmt))) printf("[015] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); print "done!"; ?> --EXPECTF-- Warning: mysqli_stmt_free_result(): invalid object or resource mysqli_stmt in %s on line %d Warning: mysqli_stmt_free_result(): Couldn't fetch mysqli_stmt in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_get_warnings.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_get_warnings.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_get_warnings.phpt --TEST-- mysqli_stmt_get_warnings() - TODO --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('connect.inc'); if (!$TEST_EXPERIMENTAL) die("skip - experimental (= unsupported) feature"); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_get_warnings())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_get_warnings($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$stmt = mysqli_stmt_init($link)) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (NULL !== ($tmp = mysqli_stmt_get_warnings($stmt))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, "DROP TABLE IF EXISTS test") || !mysqli_stmt_execute($stmt)) printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (false !== ($tmp = mysqli_stmt_get_warnings($stmt))) printf("[006] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, "CREATE TABLE test(id SMALLINT, label CHAR(1))") || !mysqli_stmt_execute($stmt)) printf("[007] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (false !== ($tmp = mysqli_stmt_get_warnings($stmt))) printf("[008] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (100000, 'a'), (100001, 'b')") || !mysqli_stmt_execute($stmt)) printf("[009] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!is_object($warning = mysqli_stmt_get_warnings($stmt))) printf("[010] Expecting mysqli_warning object, got %s/%s\n", gettype($warning), $warning); if ('mysqli_warning' !== get_class($warning)) printf("[011] Expecting object of type mysqli_warning got type '%s'", get_class($warning)); if (!method_exists($warning, 'next')) printf("[012] Object mysqli_warning seems to lack method next()\n"); $i = 0; do { if ('' == $warning->message) printf("[013 - %d] Message should not be empty\n", $i); if ('' == $warning->sqlstate) printf("[014 - %d] SQL State should not be empty\n", $i); if (0 == $warning->errno) printf("[015 - %d] Error number should not be zero\n", $i); $i++; } while ($warning->next()); if (2 != $i) printf("[016] Expected 2 warnings, got %d warnings\n", $i); mysqli_stmt_close($stmt); if (NULL !== ($tmp = mysqli_stmt_get_warnings($stmt))) printf("[015] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); print "done!"; ?> --EXPECTF-- Warning: mysqli_stmt_get_warnings(): invalid object or resource mysqli_stmt in %s on line %d Warning: mysqli_stmt_get_warnings(): Couldn't fetch mysqli_stmt in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_init.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_init.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_init.phpt --TEST-- mysqli_stmt_init() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php /* NOTE: no datatype tests here! This is done by mysqli_stmt_bind_result.phpt already. Restrict this test case to the basics. */ include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_init())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_init($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!is_object($stmt = mysqli_stmt_init($link))) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_object($stmt2 = @mysqli_stmt_init($link))) printf("[003a] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_stmt_close($stmt); if (NULL !== ($tmp = mysqli_stmt_init($stmt))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); if (NULL !== ($tmp = mysqli_stmt_init($link))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_stmt_close(): invalid object or resource mysqli_stmt in %s on line %d Warning: mysqli_stmt_init() expects parameter 1 to be mysqli, object given in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_insert_id.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_insert_id.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_insert_id.phpt --TEST-- mysqli_stmt_insert_id() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_insert_id())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); $stmt = @new mysqli_stmt($link); if (!is_null($tmp = @mysqli_insert_id($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); $stmt = mysqli_stmt_init($link); if (NULL !== ($tmp = @mysqli_stmt_insert_id($stmt))) printf("[003] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 1") || !mysqli_stmt_execute($stmt)) { printf("[004] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); } if (0 !== ($tmp = mysqli_stmt_insert_id($stmt))) printf("[005] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); // no auto_increment column $stmt = mysqli_stmt_init($link); if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (100, 'a')") || !mysqli_stmt_execute($stmt)) { printf("[006] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); } if (0 !== ($tmp = mysqli_stmt_insert_id($stmt))) printf("[007] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); if (mysqli_get_server_version($link) > 50000 && (!mysqli_stmt_prepare($stmt, "ALTER TABLE test MODIFY id INT NOT NULL AUTO_INCREMENT") || !mysqli_stmt_execute($stmt))) { printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); } else if (mysqli_get_server_version($link) < 50000){ mysqli_query($link, "ALTER TABLE test MODIFY id INT NOT NULL AUTO_INCREMENT"); } if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(label) VALUES ('a')") || !mysqli_stmt_execute($stmt)) { printf("[009] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); } if (0 === ($tmp = mysqli_stmt_insert_id($stmt))) printf("[010] Expecting int/any non zero, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); mysqli_close($link); var_dump(mysqli_stmt_insert_id($stmt)); print "done!"; ?> --EXPECTF-- Warning: mysqli_stmt_insert_id(): Couldn't fetch mysqli_stmt in %s on line %d NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_num_rows.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_num_rows.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_num_rows.phpt --TEST-- mysqli_stmt_num_rows() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_num_rows())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_num_rows($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$stmt = mysqli_stmt_init($link)) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); function func_test_mysqli_stmt_num_rows($stmt, $query, $expected, $offset) { if (!mysqli_stmt_prepare($stmt, $query)) { printf("[%03d] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_error($stmt)); return false; } if (!mysqli_stmt_execute($stmt)) { printf("[%03d] [%d] %s\n", $offset + 1, mysqli_errno($stmt), mysqli_error($stmt)); return false; } if (!mysqli_stmt_store_result($stmt)) { printf("[%03d] [%d] %s\n", $offset + 2, mysqli_errno($stmt), mysqli_error($stmt)); return false; } if ($expected !== ($tmp = mysqli_stmt_num_rows($stmt))) printf("[%03d] Expecting %s/%d, got %s/%d\n", $offset + 3, gettype($expected), $expected, gettype($tmp), $tmp); mysqli_stmt_free_result($stmt); return true; } func_test_mysqli_stmt_num_rows($stmt, "SELECT 1 AS a", 1, 10); func_test_mysqli_stmt_num_rows($stmt, "SHOW VARIABLES LIKE '%nixnutz%'", 0, 20); // Note: for statements that return no result set mysqli_num_rows() differs from mysqli_stmt_num_rows() slightly // mysqli_num_rows() failed to fetch the result set and the PHP parameter check makes it return NULL // mysqli_stmt_numrows() has a valid resource to work on and it will return int/0 instead. No bug, but // slightly different behaviour... - if you really check the data types and don't rely on casting like 98% of all PHP // users do. func_test_mysqli_stmt_num_rows($stmt, "INSERT INTO test(id, label) VALUES (100, 'z')", 0, 30); if ($res = mysqli_query($link, 'SELECT COUNT(id) AS num FROM test')) { $row = mysqli_fetch_assoc($res); mysqli_free_result($res); func_test_mysqli_stmt_num_rows($stmt, "SELECT id, label FROM test", (int)$row['num'], 40); } else { printf("[050] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } print "run_tests.php don't fool me with your 'ungreedy' expression '.+?'!\n"; if (!mysqli_stmt_prepare($stmt, 'SELECT id FROM test')) printf("[051] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (mysqli_stmt_execute($stmt)) { $i = 0; do { if (0 !== ($tmp = mysqli_stmt_num_rows($stmt))) printf("[53 - %03d] Expecting int/0, got %s/%s\n", $i, gettype($tmp), $tmp); $i++; } while (mysqli_stmt_fetch($stmt)); if (0 !== ($tmp = mysqli_stmt_num_rows($stmt))) printf("[54] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); } else { printf("[055] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); } mysqli_stmt_close($stmt); if (NULL !== ($tmp = mysqli_stmt_num_rows($stmt))) printf("[056] Expecting NULL, got %s/%s\n"); mysqli_close($link); print "done!"; ?> --EXPECTF-- run_tests.php don't fool me with your 'ungreedy' expression '.+?'! Warning: mysqli_stmt_num_rows(): Couldn't fetch mysqli_stmt in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_param_count.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_param_count.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_param_count.phpt --TEST-- mysqli_stmt_param_count() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_param_count())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_param_count($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$stmt = mysqli_stmt_init($link)) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (NULL !== ($tmp = mysqli_stmt_param_count($stmt))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); function func_test_mysqli_stmt_param_count($stmt, $query, $expected, $offset) { if (!mysqli_stmt_prepare($stmt, $query)) { printf("[%03d] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_error($stmt)); return false; } if ($expected !== ($tmp = mysqli_stmt_param_count($stmt))) printf("[%03d] Expecting %s/%d, got %s/%d\n", $offset + 3, gettype($expected), $expected, gettype($tmp), $tmp); return true; } func_test_mysqli_stmt_param_count($stmt, "SELECT 1 AS a", 0, 10); func_test_mysqli_stmt_param_count($stmt, "INSERT INTO test(id) VALUES (?)", 1, 20); func_test_mysqli_stmt_param_count($stmt, "INSERT INTO test(id, label) VALUES (?, ?)", 2, 30); func_test_mysqli_stmt_param_count($stmt, "INSERT INTO test(id, label) VALUES (?, '?')", 1, 40); mysqli_stmt_close($stmt); if (NULL !== ($tmp = mysqli_stmt_param_count($stmt))) printf("[40] Expecting NULL, got %s/%s\n"); mysqli_close($link); /* Check that the function alias exists. It's a deprecated function, but we have not announce the removal so far, therefore we need to check for it */ if (!is_null($tmp = @mysqli_param_count())) printf("[041] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_stmt_param_count(): invalid object or resource mysqli_stmt in %s on line %d Warning: mysqli_stmt_param_count(): Couldn't fetch mysqli_stmt in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_prepare.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_prepare.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_prepare.phpt --TEST-- mysqli_stmt_prepare() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; // Note: No SQL tests here! We can expand one of the *fetch() // tests to a generic SQL test, if we ever need that. // We would duplicate the SQL test cases if we have it here and in one of the // fetch tests, because the fetch tests would have to call prepare/execute etc. // anyway. $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_prepare())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_prepare($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$stmt = mysqli_stmt_init($link)) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (NULL !== ($tmp = @mysqli_stmt_prepare($stmt))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysqli_stmt_prepare($stmt, ''))) printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = mysqli_stmt_prepare($stmt, 'SELECT id FROM test'))) printf("[006] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); if (NULL !== ($tmp = mysqli_stmt_prepare($stmt, "SELECT id FROM test"))) printf("[007] Expecting NULL, got %s/%s\n"); mysqli_close($link); print "done!"; ?> --EXPECTF-- Warning: mysqli_stmt_prepare(): Couldn't fetch mysqli_stmt in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_reset.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_reset.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_reset.phpt --TEST-- mysqli_stmt_reset() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; // Note: No SQL tests here! We can expand one of the *fetch() // tests to a generic SQL test, if we ever need that. // We would duplicate the SQL test cases if we have it here and in one of the // fetch tests, because the fetch tests would have to call prepare/execute etc. // anyway. $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_reset())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_reset($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$stmt = mysqli_stmt_init($link)) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (NULL !== ($tmp = mysqli_stmt_reset($stmt))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = mysqli_stmt_prepare($stmt, 'SELECT id FROM test'))) printf("[005] Expecting boolean/true, got %s/%s, [%d] %s\n", gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (true !== ($tmp = mysqli_stmt_reset($stmt))) printf("[006] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = mysqli_stmt_execute($stmt))) printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); $id = null; if (!mysqli_stmt_bind_result($stmt, $id)) printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!mysqli_stmt_fetch($stmt)) printf("[009] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); var_dump($id); mysqli_stmt_close($stmt); if (!$stmt = mysqli_stmt_init($link)) printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, "CREATE TABLE test(id INT NOT NULL AUTO_INCREMENT, label BLOB, PRIMARY KEY(id))")) printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(label) VALUES (?)")) printf("[013] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); $label = null; if (!mysqli_stmt_bind_param($stmt, "b", $label)) printf("[014] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); $label = 'abc'; for ($i = 0; $i < 10; $i++) { if (!mysqli_stmt_send_long_data($stmt, 0, $label)) printf("[015 - %d] [%d] %s\n", $i, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); } if (!mysqli_stmt_reset($stmt)) printf("[016] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!mysqli_stmt_execute($stmt)) printf("[017] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!$res = mysqli_query($link, "SELECT label FROM test")) printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$row = mysqli_fetch_assoc($res)) printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_free_result($res); if ($row['label'] != '') printf("[020] Expecting empty string, got string/%s\n", $row['label']); mysqli_stmt_close($stmt); if (NULL !== ($tmp = mysqli_stmt_reset($stmt))) printf("[021] Expecting NULL, got %s/%s\n"); mysqli_close($link); print "done!"; ?> --EXPECTF-- Warning: mysqli_stmt_reset(): invalid object or resource mysqli_stmt in %s on line %d int(1) Warning: mysqli_stmt_reset(): Couldn't fetch mysqli_stmt in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_result_metadata.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_result_metadata.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_result_metadata.phpt --TEST-- mysqli_stmt_result_metadata() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_result_metadata())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_result_metadata($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$stmt = mysqli_stmt_init($link)) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (NULL !== ($tmp = mysqli_stmt_result_metadata($stmt))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test")) printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!is_object(($res = mysqli_stmt_result_metadata($stmt)))) printf("[006] Expecting object, got %s/%s\n", gettype($tmp), $tmp); if (2 !== ($tmp = mysqli_num_fields($res))) printf("[007] Expecting int/2, got %s/%s, [%d] %s\n", gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link)); if (!is_object($field0_fetch = mysqli_fetch_field($res))) printf("[008] Expecting object, got %s/%s, [%d] %s\n", gettype($field0_fetch), $field0_fetch, mysqli_errno($link), mysqli_error($link)); if (!is_object($field0_direct = mysqli_fetch_field_direct($res, 0))) printf("[009] Expecting object, got %s/%s, [%d] %s\n", gettype($field0_direct), $field0_direct, mysqli_errno($link), mysqli_error($link)); if ($field0_fetch != $field0_direct) { printf("[010] mysqli_fetch_field() differs from mysqli_fetch_field_direct()\n"); var_dump($field0_fetch); var_dump($field0_direct); } var_dump($field0_fetch); if (!is_array($tmp = mysqli_fetch_fields($res))) printf("[011] Expecting array, got %s/%s, [%d] %s\n", gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link)); if (empty($tmp[0]) || empty($tmp[1]) || $tmp[0] != $field0_direct) { printf("[012] mysqli_fetch_fields() return value is suspicious\n"); var_dump($tmp); } if (!mysqli_field_seek($res, 1)) printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_object($field1_direct = mysqli_fetch_field_direct($res, 1))) printf("[014] Expecting object, got %s/%s, [%d] %s\n", gettype($field1_direct), $field1_direct, mysqli_errno($link), mysqli_error($link)); if ($tmp[1] != $field1_direct) { printf("[015] mysqli_fetch_field_direct() differs from mysqli_fetch_fields()\n"); var_dump($field1_direct); var_dump($tmp); } if (1 !== ($tmp = mysqli_field_tell($res))) printf("[016] Expecting int/1, got %s/%s, [%d] %s\n", gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link)); mysqli_free_result($res); mysqli_stmt_close($stmt); if (NULL !== ($tmp = mysqli_stmt_result_metadata($stmt))) printf("[017] Expecting NULL, got %s/%s\n"); /* Check that the function alias exists. It's a deprecated function, but we have not announce the removal so far, therefore we need to check for it */ if (!is_null($tmp = @mysqli_get_metadata())) printf("[018] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); print "done!"; ?> --EXPECTF-- Warning: mysqli_stmt_result_metadata(): invalid object or resource mysqli_stmt in %s on line %d object(stdClass)#5 (%d) { ["name"]=> string(2) "id" ["orgname"]=> string(2) "id" ["table"]=> string(4) "test" ["orgtable"]=> string(4) "test" ["def"]=> string(0) "" ["max_length"]=> int(0) ["length"]=> int(11) ["charsetnr"]=> int(63) ["flags"]=> int(49155) ["type"]=> int(3) ["decimals"]=> int(0) } Warning: mysqli_stmt_result_metadata(): Couldn't fetch mysqli_stmt in %s on line %d done! --UEXPECTF-- Warning: mysqli_stmt_result_metadata(): invalid object or resource mysqli_stmt in %s on line %d object(stdClass)#5 (%d) { [u"name"]=> unicode(2) "id" [u"orgname"]=> unicode(2) "id" [u"table"]=> unicode(4) "test" [u"orgtable"]=> unicode(4) "test" [u"def"]=> unicode(0) "" [u"max_length"]=> int(0) [u"length"]=> int(11) [u"charsetnr"]=> int(63) [u"flags"]=> int(49155) [u"type"]=> int(3) [u"decimals"]=> int(0) } Warning: mysqli_stmt_result_metadata(): Couldn't fetch mysqli_stmt in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_result_metadata_sqltests.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_result_metadata_sqltests.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_result_metadata_sqltests.phpt --TEST-- mysqli_stmt_result_metadata() - non SELECT statements --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; require('table.inc'); function testStatement($offset, $link, $sql, $expected_lib, $expected_mysqlnd, $check_mysqlnd, $compare) { if (!$stmt = mysqli_stmt_init($link)) { printf("[%04d - %s] [%d] %s\n", $offset, $sql, mysqli_errno($link), mysqli_error($link)); return false; } if (!@mysqli_stmt_prepare($stmt, $sql)) { /* Not all server versions will support all statements */ /* Failing to prepare is OK */ return true; } $res = mysqli_stmt_result_metadata($stmt); if (empty($expected_lib) && (false !== $res)) { printf("[%04d - %s] No metadata expected\n", $offset + 1, $sql); return false; } else if (!empty($expected_lib) && (false == $res)) { printf("[%04d - %s] Metadata expected\n", $offset + 2, $sql); return false; } if (!empty($expected_lib)) { if (!is_object($res)) { printf("[%04d - %s] [%d] %s\n", $offset + 3, $sql, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); return false; } if (get_class($res) != 'mysqli_result') { printf("[%04d - %s] Expecting object/mysqli_result got object/%s\n", $offset + 4, $sql, get_class($res)); return false; } $meta = array( 'num_fields' => mysqli_num_fields($res), 'fetch_field' => mysqli_fetch_field($res), 'fetch_field_direct0' => mysqli_fetch_field_direct($res, 0), 'fetch_field_direct1' => @mysqli_fetch_field_direct($res, 1), 'fetch_fields' => count(mysqli_fetch_fields($res)), 'field_count' => $res->field_count, 'field_seek-1' => @mysqli_field_seek($res, -1), 'field_seek0' => mysqli_field_seek($res, 0), 'field_tell' => mysqli_field_tell($res), ); if (is_object($meta['fetch_field'])) { $meta['fetch_field']->charsetnr = 'ignore'; $meta['fetch_field']->flags = 'ignore'; } if (is_object($meta['fetch_field_direct0'])) { $meta['fetch_field_direct0']->charsetnr = 'ignore'; $meta['fetch_field_direct0']->flags = 'ignore'; } if (is_object($meta['fetch_field_direct1'])) { $meta['fetch_field_direct1']->charsetnr = 'ignore'; $meta['fetch_field_direct1']->flags = 'ignore'; } mysqli_free_result($res); if ($meta != $expected_lib) { printf("[%04d - %s] Metadata differes from expected values\n", $offset + 5, $sql); var_dump($meta); var_dump($expected_lib); return false; } } if (function_exists('mysqli_stmt_get_result')) { /* mysqlnd only */ if (!mysqli_stmt_execute($stmt)) { printf("[%04d - %s] [%d] %s\n", $offset + 6, $sql, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); return false; } $res = mysqli_stmt_get_result($stmt); if (false === $res && !empty($expected_mysqlnd)) { printf("[%04d - %s] Expecting resultset [%d] %s\n", $offset + 7, $sql, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); return false; } else if (empty($expected_mysqlnd) && false !== $res) { printf("[%04d - %s] Unexpected resultset [%d] %s\n", $offset + 8, $sql, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); return false; } if (!is_object($res)) { printf("[%04d - %s] [%d] %s\n", $offset + 9, $sql, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); return false; } if ('mysqli_result' != get_class($res)) { printf("[%04d - %s] Expecting object/mysqli_result got object/%s\n", $offset + 10, $sql, get_class($res)); return false; } $meta_res = array( 'num_fields' => mysqli_num_fields($res), 'fetch_field' => mysqli_fetch_field($res), 'fetch_field_direct0' => mysqli_fetch_field_direct($res, 0), 'fetch_field_direct1' => @mysqli_fetch_field_direct($res, 1), 'fetch_fields' => count(mysqli_fetch_fields($res)), 'field_count' => mysqli_field_count($link), 'field_seek-1' => @mysqli_field_seek($res, -1), 'field_seek0' => mysqli_field_seek($res, 0), 'field_tell' => mysqli_field_tell($res), ); if (is_object($meta_res['fetch_field'])) { $meta_res['fetch_field']->charsetnr = 'ignore'; $meta_res['fetch_field']->flags = 'ignore'; } if (is_object($meta_res['fetch_field_direct0'])) { $meta_res['fetch_field_direct0']->charsetnr = 'ignore'; $meta_res['fetch_field_direct0']->flags = 'ignore'; } if (is_object($meta_res['fetch_field_direct1'])) { $meta_res['fetch_field_direct1']->charsetnr = 'ignore'; $meta_res['fetch_field_direct1']->flags = 'ignore'; } mysqli_free_result($res); if ($check_mysqlnd && $meta_res != $expected_mysqlnd) { printf("[%04d - %s] Metadata differs from expected\n", $offset + 11, $sql); var_dump($meta_res); var_dump($expected_mysqlnd); } else { if ($meta_res['field_count'] < 1) { printf("[%04d - %s] Metadata seems wrong, no fields?\n", $offset + 12, $sql); var_dump($meta_res); var_dump(mysqli_fetch_assoc($res)); } } if ($compare && $meta_res != $meta) { printf("[%04d - %s] Metadata returned by mysqli_stmt_result_metadata() and mysqli_stmt_get_result() differ\n", $offset + 13, $sql); var_dump($meta_res); var_dump($meta); } } mysqli_stmt_close($stmt); return true; } /* Note: very weak testing, we accept almost any result */ testStatement(100, $link, 'ANALYZE TABLE test', array(), array(1), false, false); testStatement(120, $link, 'OPTIMIZE TABLE test', array(), array(1), false, false); testStatement(140, $link, 'REPAIR TABLE test', array(), array(1), false, false); testStatement(160, $link, 'SHOW AUTHORS', array(), array(1), false, false); testStatement(180, $link, 'SHOW CHARACTER SET', array(), array(1), false, false); testStatement(200, $link, 'SHOW COLLATION', array(), array(1), false, false); testStatement(220, $link, 'SHOW CONTRIBUTORS', array(), array(1), false, false); testStatement(240, $link, 'SHOW CREATE DATABASE ' . $db, array(), array(1), false, false); testStatement(260, $link, 'SHOW DATABASES', array(), array(1), false, false); testStatement(280, $link, 'SHOW ENGINE InnoDB STATUS', array(), array(1), false, false); testStatement(300, $link, 'SHOW ENGINES', array(), array(1), false, false); testStatement(320, $link, 'SHOW PLUGINS', array(), array(1), false, false); testStatement(340, $link, 'SHOW PROCESSLIST', array(), array(1), false, false); testStatement(360, $link, 'SHOW FULL PROCESSLIST', array(), array(1), false, false); testStatement(380, $link, 'SHOW STATUS', array(), array(1), false, false); testStatement(400, $link, 'SHOW TABLE STATUS', array(), array(1), false, false); testStatement(420, $link, 'SHOW TABLE STATUS', array(), array(1), false, false); testStatement(440, $link, 'SHOW TABLES', array(), array(1), false, false); testStatement(460, $link, 'SHOW OPEN TABLES', array(), array(1), false, false); testStatement(460, $link, 'SHOW VARIABLES', array(), array(1), false, false); $field0 = new stdClass(); $field0->name = 'id'; $field0->orgname = 'id'; $field0->table = 'test'; $field0->orgtable = 'test'; $field0->def = ''; $field0->max_length = 0; $field0->length = 11; $field0->charsetnr = 'ignore'; $field0->flags = 'ignore'; $field0->type = MYSQLI_TYPE_LONG; $field0->decimals = 0; $meta_lib = array( 'num_fields' => 1, 'fetch_field' => $field0, 'fetch_field_direct0' => $field0, 'fetch_field_direct1' => false, 'fetch_fields' => 1, 'field_count' => 1, 'field_seek-1' => false, 'field_seek0' => true, 'field_tell' => 0, ); $meta_mysqlnd = $meta_lib; testStatement(480, $link, 'SELECT id FROM test', $meta_lib, $meta_mysqlnd, true, true); testStatement(500, $link, 'CHECKSUM TABLE test', array(), array(1), false, false); mysqli_close($link); print "done!"; ?> --EXPECTF-- done! --UEXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_sqlstate.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_sqlstate.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_sqlstate.phpt --TEST-- mysqli_stmt_sqlstate() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_sqlstate())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_sqlstate($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!is_null($tmp = @mysqli_stmt_sqlstate($link, ''))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$stmt = mysqli_stmt_init($link)) printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (NULL !== ($tmp = mysqli_stmt_sqlstate($stmt))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, "SELECT id FROM test")) printf("[006] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if ('00000' !== ($tmp = mysqli_stmt_sqlstate($stmt))) printf("[007] Expecting string/00000, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (mysqli_stmt_prepare($stmt, "SELECT believe_me FROM i_dont_belive_that_this_table_exists")) printf("[008] Should fail! [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if ('' === ($tmp = mysqli_stmt_sqlstate($stmt))) printf("[009] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); mysqli_stmt_close($stmt); if (NULL !== ($tmp = mysqli_stmt_sqlstate($stmt))) printf("[010] Expecting NULL, got %s/%s\n"); mysqli_close($link); print "done!"; ?> --EXPECTF-- Warning: mysqli_stmt_sqlstate(): invalid object or resource mysqli_stmt in %s on line %d Warning: mysqli_stmt_sqlstate(): Couldn't fetch mysqli_stmt in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_stmt_store_result.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_stmt_store_result.phpt +++ php-src/ext/mysqli/tests/mysqli_stmt_store_result.phpt --TEST-- mysqli_stmt_store_result() --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_stmt_store_result())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_stmt_store_result($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!is_null($tmp = @mysqli_stmt_store_result(new mysqli_stmt()))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$stmt = mysqli_stmt_init($link)) printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); // stmt object status test if (NULL !== ($tmp = @mysqli_stmt_store_result($stmt))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, 'INSERT INTO test(id, label) VALUES (100, "z")') || !mysqli_stmt_execute($stmt)) printf("[006] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (true !== ($tmp = @mysqli_stmt_store_result($stmt))) printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test ORDER BY id') || !mysqli_stmt_execute($stmt)) printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!$link_buf = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[009] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); if (!$stmt_buf = mysqli_stmt_init($link_buf)) printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_stmt_prepare($stmt_buf, "SELECT id, label FROM test ORDER BY id") || !mysqli_stmt_execute($stmt_buf)) printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt_buf), mysqli_stmt_error($stmt_buf)); $id = $label = $id_buf = $label_buf = null; if (!mysqli_stmt_bind_result($stmt, $id, $label)) printf("[012] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!mysqli_stmt_bind_result($stmt_buf, $id_buf, $label_buf)) printf("[013] [%d] %s\n", mysqli_stmt_errno($stmt_buf), mysqli_stmt_error($stmt_buf)); while (mysqli_stmt_fetch($stmt)) { if (!mysqli_stmt_fetch($stmt_buf)) { printf("[014] Unbuffered statement indicates more rows than buffered, [%d] %s\n", mysqli_stmt_errno($stmt_buf), mysqli_stmt_error($stmt_buf)); } if ($id !== $id_buf) printf("[015] unbuffered '%s'/%s, buffered '%s'/%s\n", $id, gettype($id), $id_buf, gettype($id_buf)); if ($label !== $label_buf) printf("[016] unbuffered '%s'/%s, buffered '%s'/%s\n", $label, gettype($label), $label_buf, gettype($label_buf)); } mysqli_stmt_close($stmt); mysqli_stmt_close($stmt_buf); if (NULL !== ($tmp = @mysqli_stmt_store_result($stmt))) printf("[017] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); mysqli_close($link_buf); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_store_result.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_store_result.phpt +++ php-src/ext/mysqli/tests/mysqli_store_result.phpt --TEST-- mysqli_store_result() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_store_result())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_store_result($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id")) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_object($res = mysqli_store_result($link))) printf("[004] Expecting object, got %s/%s. [%d] %s\n", gettype($res), $res, mysqli_errno($link), mysqli_error($link)); if (true !== ($tmp = mysqli_data_seek($res, 2))) printf("[005] Expecting boolean/true, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link)); mysqli_free_result($res); if (!mysqli_query($link, "DELETE FROM test")) printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (false !== ($res = mysqli_store_result($link))) printf("[007] Expecting boolean/false, got %s/%s. [%d] %s\n", gettype($res), $res, mysqli_errno($link), mysqli_error($link)); if (!$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id")) printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (false !== ($tmp = mysqli_data_seek($res, 1))) printf("[009] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); if (NULL !== ($tmp = mysqli_store_result($link))) printf("[010] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_store_result(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_thread_id.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_thread_id.phpt +++ php-src/ext/mysqli/tests/mysqli_thread_id.phpt --TEST-- mysqli_thread_id() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_thread_id())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_thread_id($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!is_int($tmp = mysqli_thread_id($link)) || (0 === $tmp)) printf("[003] Expecting int/any but zero, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link)); // should work if the thread id is correct mysqli_kill($link, mysqli_thread_id($link)); mysqli_close($link); if (NULL !== ($tmp = mysqli_thread_id($link))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_thread_id(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_thread_safe.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_thread_safe.phpt +++ php-src/ext/mysqli/tests/mysqli_thread_safe.phpt --TEST-- mysqli_thread_safe() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php if (!is_bool($tmp = mysqli_thread_safe())) printf("[001] Expecting boolean/any, got %s/%s.\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_use_result.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_use_result.phpt +++ php-src/ext/mysqli/tests/mysqli_use_result.phpt --TEST-- mysqli_use_result() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_use_result())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_use_result($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id")) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_object($res = mysqli_use_result($link))) printf("[004] Expecting object, got %s/%s. [%d] %s\n", gettype($res), $res, mysqli_errno($link), mysqli_error($link)); if (false !== ($tmp = mysqli_data_seek($res, 2))) printf("[005] Expecting boolean/true, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link)); mysqli_free_result($res); if (!mysqli_query($link, "DELETE FROM test")) printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (false !== ($res = mysqli_use_result($link))) printf("[007] Expecting boolean/false, got %s/%s. [%d] %s\n", gettype($res), $res, mysqli_errno($link), mysqli_error($link)); if (!$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id")) printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (false !== ($tmp = mysqli_data_seek($res, 1))) printf("[009] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); if (NULL !== ($tmp = mysqli_use_result($link))) printf("[010] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_data_seek(): Function cannot be used with MYSQL_USE_RESULT in %s on line %d Warning: mysqli_use_result(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_warning_count.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_warning_count.phpt +++ php-src/ext/mysqli/tests/mysqli_warning_count.phpt --TEST-- mysqli_warning_count() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_warning_count())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_warning_count($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (NULL !== ($tmp = @mysqli_warning_count($link, "too_many"))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$res = mysqli_query($link, "SELECT id, label FROM test")) printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (0 !== ($tmp = mysqli_warning_count($link))) printf("[005] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, "DROP TABLE IF EXISTS this_table_does_not_exist")) printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (1 !== ($tmp = mysqli_warning_count($link))) printf("[007] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); if (NULL !== ($tmp = mysqli_warning_count($link))) printf("[010] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_warning_count(): Couldn't fetch mysqli in %s on line %d done!