cvs: php-src(PHP_5_3) /ext/mysqli/tests mysqli_query.phpt mysqli_query_stored_proc.phpt mysqli_query_unicode.phpt mysqli_real_connect.phpt
mysqli_real_connect_pconn.phpt mysqli_real_escape_string.phpt mysqli_real_escape_string_big5.phpt mysqli_real_escape_string_eucjpms.phpt
mysqli_real_escape_string_euckr.phpt mysqli_real_escape_string_gb2312.phpt mysqli_real_escape_string_gbk.phpt
mysqli_real_escape_string_nobackslash.phpt mysqli_real_escape_string_sjis.phpt mysqli_real_escape_string_unicode.phpt mysqli_real_query.phpt
mysqli_reconnect.phpt mysqli_report.phpt mysqli_report_wo_ps.phpt mysqli_result_references.phpt mysqli_result_references_mysqlnd.phpt
mysqli_result_unclonable.phpt mysqli_rollback.phpt mysqli_rpl_parse_enabled.phpt mysqli_rpl_probe.phpt mysqli_rpl_query_type.phpt
| From: | Ulf Wendel | Date: | Wed, 10 Oct 2007 10:18:29 +0000 |
| Subject: | cvs: php-src(PHP_5_3) /ext/mysqli/tests mysqli_query.phpt mysqli_query_stored_proc.phpt mysqli_query_unicode.phpt mysqli_real_connect.phpt mysqli_real_connect_pconn.phpt mysqli_real_escape_string.phpt mysqli_real_escape_string_big5.phpt mysqli_real_escape_string_eucjpms.phpt mysqli_real_escape_string_euckr.phpt mysqli_real_escape_string_gb2312.phpt mysqli_real_escape_string_gbk.phpt mysqli_real_escape_string_nobackslash.phpt mysqli_real_escape_string_sjis.phpt mysqli_real_escape_string_unicode.phpt mysqli_real_query.phpt mysqli_reconnect.phpt mysqli_report.phpt mysqli_report_wo_ps.phpt mysqli_result_references.phpt mysqli_result_references_mysqlnd.phpt mysqli_result_unclonable.phpt mysqli_rollback.phpt mysqli_rpl_parse_enabled.phpt mysqli_rpl_probe.phpt mysqli_rpl_query_type.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-46605@lists.php.net to get a copy of this message | ||
uw Wed Oct 10 10:18:29 2007 UTC
Added files: (Branch: PHP_5_3)
/php-src/ext/mysqli/tests mysqli_query.phpt
mysqli_query_stored_proc.phpt
mysqli_query_unicode.phpt
mysqli_real_connect_pconn.phpt
mysqli_real_connect.phpt
mysqli_real_escape_string_big5.phpt
mysqli_real_escape_string_eucjpms.phpt
mysqli_real_escape_string_euckr.phpt
mysqli_real_escape_string_gb2312.phpt
mysqli_real_escape_string_gbk.phpt
mysqli_real_escape_string_nobackslash.phpt
mysqli_real_escape_string.phpt
mysqli_real_escape_string_sjis.phpt
mysqli_real_escape_string_unicode.phpt
mysqli_real_query.phpt
mysqli_reconnect.phpt mysqli_report.phpt
mysqli_report_wo_ps.phpt
mysqli_result_references_mysqlnd.phpt
mysqli_result_references.phpt
mysqli_result_unclonable.phpt
mysqli_rollback.phpt
mysqli_rpl_parse_enabled.phpt
mysqli_rpl_probe.phpt
mysqli_rpl_query_type.phpt
Log:
Adding new tests: mysqli_q*.phpt mysqli_r*.phpt
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_stored_proc.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_query_stored_proc.phpt +++ php-src/ext/mysqli/tests/mysqli_query_stored_proc.phpt 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_connect_pconn.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_real_connect_pconn.phpt +++ php-src/ext/mysqli/tests/mysqli_real_connect_pconn.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_real_connect.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_real_connect.phpt +++ php-src/ext/mysqli/tests/mysqli_real_connect.phpt --TEST-- mysqli_real_connect() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --INI-- open_basedir=. --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (NULL !== ($tmp = @mysqli_real_connect($link))) printf("[001a] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_real_connect($link, $link))) printf("[001b] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_real_connect($link, $link, $link))) printf("[001c] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_real_connect($link, $link, $link, $link))) printf("[001d] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_real_connect($link, $link, $link, $link, $link))) printf("[001e] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_real_connect($link, $link, $link, $link, $link, $link))) printf("[001f] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_real_connect($link, $link, $link, $link, $link, $link, $link))) printf("[001g] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); // ( mysqli link [, string hostname [, string username [, string passwd [, string dbname [, int port [, string socket [, int flags]]]]]]] if (NULL !== ($tmp = @mysqli_real_connect($link, $link, $link, $link, $link, $link, $link, $link))) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_init()) printf("[002] mysqli_init() failed\n"); if (!mysqli_real_connect($link, $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); mysqli_close($link); if (!$link = mysqli_init()) printf("[004] mysqli_init() failed\n"); if (false !== ($tmp = mysqli_real_connect($link, $host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket))) printf("[005] Expecting boolean/false got %s/%s. Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", gettype($tmp), $tmp, $host, $user . 'unknown_really', $db, $port, $socket); // Run the following tests without an anoynmous MySQL user and use a password for the test user! ini_set('mysqli.default_socket', $socket); if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port)) { printf("[006] Usage of mysqli.default_socket failed\n"); } else { mysqli_close($link); if (!$link = mysqli_init()) printf("[007] mysqli_init() failed\n"); } ini_set('mysqli.default_port', $port); if (!mysqli_real_connect($link, $host, $user, $passwd, $db)) { printf("[008] Usage of mysqli.default_port failed\n"); } else { mysqli_close($link); if (!$link = mysqli_init()) printf("[009] mysqli_init() failed\n"); } ini_set('mysqli.default_pw', $passwd); if (!mysqli_real_connect($link, $host, $user)) { printf("[010] Usage of mysqli.default_pw failed\n") ; } else { mysqli_close($link); if (!$link = mysqli_init()) printf("[011] mysqli_init() failed\n"); } ini_set('mysqli.default_user', $user); if (!mysqli_real_connect($link, $host)) { printf("[012] Usage of mysqli.default_user failed\n") ; } else { mysqli_close($link); if (!$link = mysqli_init()) printf("[011] mysqli_init() failed\n"); } ini_set('mysqli.default_host', $host); if (!mysqli_real_connect($link)) { printf("[014] Usage of mysqli.default_host failed\n") ; } else { mysqli_close($link); if (!$link = mysqli_init()) printf("[015] mysqli_init() failed\n"); } // CLIENT_MULTI_STATEMENTS - should be disabled silently if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, 65536)) printf("[016] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (mysqli_query($link, "SELECT 1 AS a; SELECT 2 AS b")) printf("[017] Should have failed. CLIENT_MULTI_STATEMENT should have been disabled.\n"); mysqli_close($link); if (!$link = mysqli_init()) printf("[018] mysqli_init() failed\n"); if (ini_get('open_basedir')) { // CLIENT_LOCAL_FILES should be blocked - but how to test it ?! if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, 128)) printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $filename = sys_get_temp_dir() . DIRECTORY_SEPERATOR . 'mysqli_real_connect_phpt'; if (!$fp = fopen($filename, 'w')) printf("[020] Cannot open temporary file %s\n", $filename); fwrite($fp, '100;z'); fclose($fp); // how do we test if gets forbidden because of a missing right or the flag, this test is partly bogus ? if (mysqli_query($link, "LOAD DATA LOCAL INFILE '$filename' INTO TABLE test FIELDS TERMINATED BY ';'")) printf("[021] LOAD DATA INFILE should have been forbidden!\n"); unlink($filename); } mysqli_close($link); if (NULL !== ($tmp = mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))) printf("[022] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_real_connect(): (%d/%d): Access denied for user '%s'@'%s' (using password: YES) in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_real_escape_string_big5.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_real_escape_string_big5.phpt +++ php-src/ext/mysqli/tests/mysqli_real_escape_string_big5.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_real_escape_string_eucjpms.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_real_escape_string_eucjpms.phpt +++ php-src/ext/mysqli/tests/mysqli_real_escape_string_eucjpms.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_real_escape_string_euckr.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_real_escape_string_euckr.phpt +++ php-src/ext/mysqli/tests/mysqli_real_escape_string_euckr.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_real_escape_string_gb2312.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_real_escape_string_gb2312.phpt +++ php-src/ext/mysqli/tests/mysqli_real_escape_string_gb2312.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_real_escape_string_gbk.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_real_escape_string_gbk.phpt +++ php-src/ext/mysqli/tests/mysqli_real_escape_string_gbk.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_real_escape_string_nobackslash.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_real_escape_string_nobackslash.phpt +++ php-src/ext/mysqli/tests/mysqli_real_escape_string_nobackslash.phpt 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_sjis.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_real_escape_string_sjis.phpt +++ php-src/ext/mysqli/tests/mysqli_real_escape_string_sjis.phpt 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_reconnect.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_reconnect.phpt +++ php-src/ext/mysqli/tests/mysqli_reconnect.phpt 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_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_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_unclonable.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_result_unclonable.phpt +++ php-src/ext/mysqli/tests/mysqli_result_unclonable.phpt --TEST-- Trying to clone mysqli_result object --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "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); if (!($res = mysqli_query($link, "SELECT 'good' AS morning"))) printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $res_clone = clone $res; print "done!"; ?> --EXPECTF-- Fatal error: Trying to clone an uncloneable object of class mysqli_result in %s on line %d 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_rpl_parse_enabled.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_rpl_parse_enabled.phpt +++ php-src/ext/mysqli/tests/mysqli_rpl_parse_enabled.phpt --TEST-- mysqli_rpl_parse_enabled() --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('skipifconnectfailure.inc'); if (!function_exists('mysqli_rpl_parse_enabled')) { die("skip mysqli_rpl_parse_enabled() not available"); } require_once('connect.inc'); if (!$TEST_EXPERIMENTAL) die("skip - experimental (= unsupported) feature"); ?> --FILE-- <?php /* NOTE: tests is a stub, but function is deprecated, as long as it does not crash when invoking it... */ include "connect.inc"; $tmp = NULL; $link = NULL; if (NULL !== ($tmp = @mysqli_rpl_parse_enabled())) printf("[001] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_rpl_parse_enabled($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_int($tmp = mysqli_rpl_parse_enabled($link))) printf("[004] Expecting integer/any value, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); if (NULL !== ($tmp = mysqli_rpl_parse_enabled($link))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_rpl_parse_enabled(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_rpl_probe.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_rpl_probe.phpt +++ php-src/ext/mysqli/tests/mysqli_rpl_probe.phpt --TEST-- mysqli_rpl_probe() --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('skipifconnectfailure.inc'); if (!function_exists('mysqli_rpl_probe')) { die("skip mysqli_rpl_probe() not available"); } require_once('connect.inc'); if (!$TEST_EXPERIMENTAL) die("skip - experimental (= unsupported) feature"); ?> --FILE-- <?php /* NOTE: tests is a stub, but function is deprecated, as long as it does not crash when invoking it... */ include "connect.inc"; $tmp = NULL; $link = NULL; if (NULL !== ($tmp = @mysqli_rpl_probe())) printf("[001] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_rpl_probe($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_rpl_probe($link))) printf("[004] Expecting boolean/any value, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); if (NULL !== ($tmp = mysqli_rpl_probe($link))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_rpl_probe(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_rpl_query_type.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_rpl_query_type.phpt +++ php-src/ext/mysqli/tests/mysqli_rpl_query_type.phpt --TEST-- mysqli_rpl_query_type() --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('skipifconnectfailure.inc'); if (!function_exists('mysqli_rpl_query_type')) { die("skip mysqli_rpl_query_type() not available"); } require_once('connect.inc'); if (!$TEST_EXPERIMENTAL) die("skip - experimental (= unsupported) feature"); ?> --FILE-- <?php /* NOTE: tests is a stub, but function is deprecated, as long as it does not crash when invoking it... */ include "connect.inc"; $tmp = NULL; $link = NULL; if (NULL !== ($tmp = @mysqli_rpl_query_type())) printf("[001] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_rpl_query_type($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); } $query = array(); if (NULL !== ($tmp = @mysqli_rpl_query_type($link, $query))) printf("[004] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_int($tmp = mysqli_rpl_query_type($link, 'SELECT 1'))) printf("[005] Expecting integer/any value, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); if (NULL !== ($tmp = mysqli_rpl_query_type($link, 'SELECT 1'))) printf("[006] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_rpl_query_type(): Couldn't fetch mysqli in %s on line %d 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_stored_proc.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_query_stored_proc.phpt +++ php-src/ext/mysqli/tests/mysqli_query_stored_proc.phpt 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_connect_pconn.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_real_connect_pconn.phpt +++ php-src/ext/mysqli/tests/mysqli_real_connect_pconn.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_real_connect.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_real_connect.phpt +++ php-src/ext/mysqli/tests/mysqli_real_connect.phpt --TEST-- mysqli_real_connect() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --INI-- open_basedir=. --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (NULL !== ($tmp = @mysqli_real_connect($link))) printf("[001a] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_real_connect($link, $link))) printf("[001b] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_real_connect($link, $link, $link))) printf("[001c] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_real_connect($link, $link, $link, $link))) printf("[001d] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_real_connect($link, $link, $link, $link, $link))) printf("[001e] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_real_connect($link, $link, $link, $link, $link, $link))) printf("[001f] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_real_connect($link, $link, $link, $link, $link, $link, $link))) printf("[001g] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); // ( mysqli link [, string hostname [, string username [, string passwd [, string dbname [, int port [, string socket [, int flags]]]]]]] if (NULL !== ($tmp = @mysqli_real_connect($link, $link, $link, $link, $link, $link, $link, $link))) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_init()) printf("[002] mysqli_init() failed\n"); if (!mysqli_real_connect($link, $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); mysqli_close($link); if (!$link = mysqli_init()) printf("[004] mysqli_init() failed\n"); if (false !== ($tmp = mysqli_real_connect($link, $host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket))) printf("[005] Expecting boolean/false got %s/%s. Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", gettype($tmp), $tmp, $host, $user . 'unknown_really', $db, $port, $socket); // Run the following tests without an anoynmous MySQL user and use a password for the test user! ini_set('mysqli.default_socket', $socket); if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port)) { printf("[006] Usage of mysqli.default_socket failed\n"); } else { mysqli_close($link); if (!$link = mysqli_init()) printf("[007] mysqli_init() failed\n"); } ini_set('mysqli.default_port', $port); if (!mysqli_real_connect($link, $host, $user, $passwd, $db)) { printf("[008] Usage of mysqli.default_port failed\n"); } else { mysqli_close($link); if (!$link = mysqli_init()) printf("[009] mysqli_init() failed\n"); } ini_set('mysqli.default_pw', $passwd); if (!mysqli_real_connect($link, $host, $user)) { printf("[010] Usage of mysqli.default_pw failed\n") ; } else { mysqli_close($link); if (!$link = mysqli_init()) printf("[011] mysqli_init() failed\n"); } ini_set('mysqli.default_user', $user); if (!mysqli_real_connect($link, $host)) { printf("[012] Usage of mysqli.default_user failed\n") ; } else { mysqli_close($link); if (!$link = mysqli_init()) printf("[011] mysqli_init() failed\n"); } ini_set('mysqli.default_host', $host); if (!mysqli_real_connect($link)) { printf("[014] Usage of mysqli.default_host failed\n") ; } else { mysqli_close($link); if (!$link = mysqli_init()) printf("[015] mysqli_init() failed\n"); } // CLIENT_MULTI_STATEMENTS - should be disabled silently if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, 65536)) printf("[016] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (mysqli_query($link, "SELECT 1 AS a; SELECT 2 AS b")) printf("[017] Should have failed. CLIENT_MULTI_STATEMENT should have been disabled.\n"); mysqli_close($link); if (!$link = mysqli_init()) printf("[018] mysqli_init() failed\n"); if (ini_get('open_basedir')) { // CLIENT_LOCAL_FILES should be blocked - but how to test it ?! if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, 128)) printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $filename = sys_get_temp_dir() . DIRECTORY_SEPERATOR . 'mysqli_real_connect_phpt'; if (!$fp = fopen($filename, 'w')) printf("[020] Cannot open temporary file %s\n", $filename); fwrite($fp, '100;z'); fclose($fp); // how do we test if gets forbidden because of a missing right or the flag, this test is partly bogus ? if (mysqli_query($link, "LOAD DATA LOCAL INFILE '$filename' INTO TABLE test FIELDS TERMINATED BY ';'")) printf("[021] LOAD DATA INFILE should have been forbidden!\n"); unlink($filename); } mysqli_close($link); if (NULL !== ($tmp = mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))) printf("[022] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_real_connect(): (%d/%d): Access denied for user '%s'@'%s' (using password: YES) in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_real_escape_string_big5.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_real_escape_string_big5.phpt +++ php-src/ext/mysqli/tests/mysqli_real_escape_string_big5.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_real_escape_string_eucjpms.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_real_escape_string_eucjpms.phpt +++ php-src/ext/mysqli/tests/mysqli_real_escape_string_eucjpms.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_real_escape_string_euckr.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_real_escape_string_euckr.phpt +++ php-src/ext/mysqli/tests/mysqli_real_escape_string_euckr.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_real_escape_string_gb2312.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_real_escape_string_gb2312.phpt +++ php-src/ext/mysqli/tests/mysqli_real_escape_string_gb2312.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_real_escape_string_gbk.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_real_escape_string_gbk.phpt +++ php-src/ext/mysqli/tests/mysqli_real_escape_string_gbk.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_real_escape_string_nobackslash.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_real_escape_string_nobackslash.phpt +++ php-src/ext/mysqli/tests/mysqli_real_escape_string_nobackslash.phpt 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_sjis.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_real_escape_string_sjis.phpt +++ php-src/ext/mysqli/tests/mysqli_real_escape_string_sjis.phpt 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_reconnect.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_reconnect.phpt +++ php-src/ext/mysqli/tests/mysqli_reconnect.phpt 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_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_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_unclonable.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_result_unclonable.phpt +++ php-src/ext/mysqli/tests/mysqli_result_unclonable.phpt --TEST-- Trying to clone mysqli_result object --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "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); if (!($res = mysqli_query($link, "SELECT 'good' AS morning"))) printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $res_clone = clone $res; print "done!"; ?> --EXPECTF-- Fatal error: Trying to clone an uncloneable object of class mysqli_result in %s on line %d 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_rpl_parse_enabled.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_rpl_parse_enabled.phpt +++ php-src/ext/mysqli/tests/mysqli_rpl_parse_enabled.phpt --TEST-- mysqli_rpl_parse_enabled() --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('skipifconnectfailure.inc'); if (!function_exists('mysqli_rpl_parse_enabled')) { die("skip mysqli_rpl_parse_enabled() not available"); } require_once('connect.inc'); if (!$TEST_EXPERIMENTAL) die("skip - experimental (= unsupported) feature"); ?> --FILE-- <?php /* NOTE: tests is a stub, but function is deprecated, as long as it does not crash when invoking it... */ include "connect.inc"; $tmp = NULL; $link = NULL; if (NULL !== ($tmp = @mysqli_rpl_parse_enabled())) printf("[001] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_rpl_parse_enabled($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_int($tmp = mysqli_rpl_parse_enabled($link))) printf("[004] Expecting integer/any value, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); if (NULL !== ($tmp = mysqli_rpl_parse_enabled($link))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_rpl_parse_enabled(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_rpl_probe.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_rpl_probe.phpt +++ php-src/ext/mysqli/tests/mysqli_rpl_probe.phpt --TEST-- mysqli_rpl_probe() --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('skipifconnectfailure.inc'); if (!function_exists('mysqli_rpl_probe')) { die("skip mysqli_rpl_probe() not available"); } require_once('connect.inc'); if (!$TEST_EXPERIMENTAL) die("skip - experimental (= unsupported) feature"); ?> --FILE-- <?php /* NOTE: tests is a stub, but function is deprecated, as long as it does not crash when invoking it... */ include "connect.inc"; $tmp = NULL; $link = NULL; if (NULL !== ($tmp = @mysqli_rpl_probe())) printf("[001] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_rpl_probe($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_rpl_probe($link))) printf("[004] Expecting boolean/any value, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); if (NULL !== ($tmp = mysqli_rpl_probe($link))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_rpl_probe(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_rpl_query_type.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_rpl_query_type.phpt +++ php-src/ext/mysqli/tests/mysqli_rpl_query_type.phpt --TEST-- mysqli_rpl_query_type() --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('skipifconnectfailure.inc'); if (!function_exists('mysqli_rpl_query_type')) { die("skip mysqli_rpl_query_type() not available"); } require_once('connect.inc'); if (!$TEST_EXPERIMENTAL) die("skip - experimental (= unsupported) feature"); ?> --FILE-- <?php /* NOTE: tests is a stub, but function is deprecated, as long as it does not crash when invoking it... */ include "connect.inc"; $tmp = NULL; $link = NULL; if (NULL !== ($tmp = @mysqli_rpl_query_type())) printf("[001] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysqli_rpl_query_type($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); } $query = array(); if (NULL !== ($tmp = @mysqli_rpl_query_type($link, $query))) printf("[004] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_int($tmp = mysqli_rpl_query_type($link, 'SELECT 1'))) printf("[005] Expecting integer/any value, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); if (NULL !== ($tmp = mysqli_rpl_query_type($link, 'SELECT 1'))) printf("[006] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_rpl_query_type(): Couldn't fetch mysqli in %s on line %d done!