cvs: php-src /ext/mysql/tests mysql_affected_rows.phpt mysql_client_encoding.phpt mysql_close.phpt mysql_connect.phpt mysql_create_db.phpt
mysql_data_seek.phpt mysql_db_name.phpt mysql_db_query.phpt mysql_drop_db.phpt mysql_errno.phpt mysql_error.phpt mysql_escape_string.phpt
mysql_fetch_array.phpt mysql_fetch_assoc.phpt mysql_fetch_field.phpt mysql_fetch_lengths.phpt mysql_fetch_object.phpt mysql_fetch_row.phpt
mysql_field_flags.phpt mysql_field_len.phpt mysql_field_name.phpt mysql_field_seek.phpt mysql_field_table.phpt mysql_field_type.phpt
mysql_free_result.phpt mysql_get_client_info.phpt mysql_get_host_info.phpt mysql_get_proto_info.phpt mysql_get_server_info.phpt mysql_info.phpt
mysql_insert_id.phpt mysql_list_dbs.phpt mysql_list_fields.phpt mysql_list_processes.phpt mysql_num_fields.phpt mysql_num_rows.phpt
mysql_pconnect.phpt mysql_ping.phpt mysql_query.phpt mysql_real_escape_string.phpt mysql_result.phpt mysql_select_db.phpt mysql_stat.phpt
mysql_tablename.p! hpt mysql_thread_id.phpt mysql_unbuffered_query.phpt table.inc

From: Date: Sun, 19 Nov 2006 12:14:45 +0000
Subject: cvs: php-src /ext/mysql/tests mysql_affected_rows.phpt mysql_client_encoding.phpt mysql_close.phpt mysql_connect.phpt mysql_create_db.phpt
mysql_data_seek.phpt mysql_db_name.phpt mysql_db_query.phpt mysql_drop_db.phpt mysql_errno.phpt mysql_error.phpt mysql_escape_string.phpt
mysql_fetch_array.phpt mysql_fetch_assoc.phpt mysql_fetch_field.phpt mysql_fetch_lengths.phpt mysql_fetch_object.phpt mysql_fetch_row.phpt
mysql_field_flags.phpt mysql_field_len.phpt mysql_field_name.phpt mysql_field_seek.phpt mysql_field_table.phpt mysql_field_type.phpt
mysql_free_result.phpt mysql_get_client_info.phpt mysql_get_host_info.phpt mysql_get_proto_info.phpt mysql_get_server_info.phpt mysql_info.phpt
mysql_insert_id.phpt mysql_list_dbs.phpt mysql_list_fields.phpt mysql_list_processes.phpt mysql_num_fields.phpt mysql_num_rows.phpt
mysql_pconnect.phpt mysql_ping.phpt mysql_query.phpt mysql_real_escape_string.phpt mysql_result.phpt mysql_select_db.phpt mysql_stat.phpt
mysql_tablename.p! hpt mysql_thread_id.phpt mysql_unbuffered_query.phpt table.inc
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-41633@lists.php.net to get a copy of this message
georg Sun Nov 19 12:14:45 2006 UTC Added files: /php-src/ext/mysql/tests mysql_affected_rows.phpt mysql_client_encoding.phpt mysql_close.phpt mysql_connect.phpt mysql_create_db.phpt mysql_data_seek.phpt mysql_db_name.phpt mysql_db_query.phpt mysql_drop_db.phpt mysql_errno.phpt mysql_error.phpt mysql_escape_string.phpt mysql_fetch_array.phpt mysql_fetch_assoc.phpt mysql_fetch_field.phpt mysql_fetch_lengths.phpt mysql_fetch_object.phpt mysql_fetch_row.phpt mysql_field_flags.phpt mysql_field_len.phpt mysql_field_name.phpt mysql_field_seek.phpt mysql_field_table.phpt mysql_field_type.phpt mysql_free_result.phpt mysql_get_client_info.phpt mysql_get_host_info.phpt mysql_get_proto_info.phpt mysql_get_server_info.phpt mysql_info.phpt mysql_insert_id.phpt mysql_list_dbs.phpt mysql_list_fields.phpt mysql_list_processes.phpt mysql_num_fields.phpt mysql_num_rows.phpt mysql_pconnect.phpt mysql_ping.phpt mysql_query.phpt mysql_real_escape_string.phpt mysql_result.phpt mysql_select_db.phpt mysql_stat.phpt mysql_tablename.phpt mysql_thread_id.phpt mysql_unbuffered_query.phpt table.inc Log: added testcases for ext/mysql (written by Ulf Wendel)

http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_affected_rows.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_affected_rows.phpt +++ php-src/ext/mysql/tests/mysql_affected_rows.phpt --TEST-- mysql_affected_rows() --SKIPIF-- <?php // require_once('skipif.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (false !== ($tmp = @mysql_affected_rows())) printf("[001] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = @mysql_affected_rows($link))) printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysql_affected_rows($link, $link))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) printf("[004] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (-1 !== ($tmp = mysql_affected_rows($link))) printf("[005] Expecting int/-1, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysql_errno($link), mysql_error($link)); if (!mysql_query('DROP TABLE IF EXISTS test', $link)) printf("[006] [%d] %s\n", mysql_errno($link), mysql_error($link)); if (!mysql_query('CREATE TABLE test(id INT, label CHAR(1), PRIMARY KEY(id)) ENGINE = ' . $engine, $link)) printf("[007] [%d] %s\n", mysql_errno($link), mysql_error($link)); if (!mysql_query('INSERT INTO test(id, label) VALUES (1, "a")', $link)) printf("[008] [%d] %s\n", mysql_errno($link), mysql_error($link)); if (1 !== ($tmp = mysql_affected_rows($link))) printf("[010] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); // ignore INSERT error, NOTE: command line returns 0, affected_rows returns -1 as documented mysql_query('INSERT INTO test(id, label) VALUES (1, "a")', $link); if (-1 !== ($tmp = mysql_affected_rows($link))) printf("[011] Expecting int/-1, got %s/%s\n", gettype($tmp), $tmp); if (!mysql_query('INSERT INTO test(id, label) VALUES (1, "a") ON DUPLICATE KEY UPDATE id = 4', $link)) printf("[012] [%d] %s\n", mysql_errno($link), mysql_error($link)); if (2 !== ($tmp = mysql_affected_rows($link))) printf("[013] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp); if (!mysql_query("INSERT INTO test(id, label) VALUES (2, 'b'), (3, 'c')", $link)) printf("[014] [%d] %s\n", mysql_errno($link), mysql_error($link)); if (2 !== ($tmp = mysql_affected_rows($link))) printf("[015] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp); if (!mysql_query("INSERT IGNORE INTO test(id, label) VALUES (1, 'a')", $link)) { printf("[016] [%d] %s\n", mysql_errno($link), mysql_error($link)); } if (1 !== ($tmp = mysql_affected_rows($link))) printf("[017] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); if (!mysql_query("INSERT INTO test(id, label) SELECT id + 10, label FROM test", $link)) printf("[018] [%d] %s\n", mysql_errno($link), mysql_error($link)); if (4 !== ($tmp = mysql_affected_rows($link))) printf("[019] Expecting int/4, got %s/%s\n", gettype($tmp), $tmp); if (!mysql_query("REPLACE INTO test(id, label) values (4, 'd')", $link)) printf("[020] [%d] %s\n", mysql_errno($link), mysql_error($link)); if (2 !== ($tmp = mysql_affected_rows($link))) printf("[021] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp); if (!mysql_query("REPLACE INTO test(id, label) values (5, 'e')", $link)) printf("[022] [%d] %s\n", mysql_errno($link), mysql_error($link)); if (1 !== ($tmp = mysql_affected_rows($link))) printf("[023] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); if (!mysql_query("UPDATE test SET label = 'a' WHERE id = 2", $link)) printf("[024] [%d] %s\n", mysql_errno($link), mysql_error($link)); if (1 !== ($tmp = mysql_affected_rows($link))) printf("[025] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); if (!mysql_query("UPDATE test SET label = 'a' WHERE id = 2", $link)) { printf("[025] [%d] %s\n", mysql_errno($link), mysql_error($link)); } if (0 !== ($tmp = mysql_affected_rows($link))) printf("[026] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); if (!mysql_query("UPDATE test SET label = 'a' WHERE id = 100", $link)) { printf("[025] [%d] %s\n", mysql_errno($link), mysql_error($link)); } if (0 !== ($tmp = mysql_affected_rows($link))) printf("[026] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); if (!mysql_query('DROP TABLE IF EXISTS test', $link)) printf("[027] [%d] %s\n", mysql_errno($link), mysql_error($link)); mysql_close($link); if (false !== ($tmp = @mysql_affected_rows($link))) printf("[028] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_client_encoding.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_client_encoding.phpt +++ php-src/ext/mysql/tests/mysql_client_encoding.phpt --TEST-- mysql_client_encoding() --SKIPIF-- <?php require_once('skipif.inc'); ?> --FILE-- <?php include_once "connect.inc"; $tmp = NULL; $link = NULL; if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); $default_link_enc = mysql_client_encoding(); $link_enc = mysql_client_encoding($link); if ($default_link_enc !== $link_enc) printf("[003] %s != %s, [%d] %s\n", $default_link_enc, $link_enc, mysql_errno($link), mysql_error($link)); if (!$res = mysql_query('SELECT version() AS server_version', $link)) printf("[004] [%d] %s\n", mysql_errno($link), mysql_error($link)); $tmp = mysql_fetch_assoc($res); mysql_free_result($res); $version = explode('.', $tmp['server_version']); if (empty($version)) printf("[005] Cannot determine server version, need MySQL Server 4.1+ for the test!\n"); if ($version[0] <= 4 && $version[1] < 1) printf("[006] Need MySQL Server 4.1+ for the test!\n"); if (!$res = mysql_query('SELECT @@character_set_connection AS charset, @@collation_connection AS collation', $link)) printf("[007] [%d] %s\n", mysql_errno($link), mysql_error($link)); $tmp = mysql_fetch_assoc($res); mysql_free_result($res); if (!$tmp['charset']) printf("[008] Cannot determine current character set and collation\n"); if ($link_enc !== $tmp['charset']) { if ($link_enc === $tmp['collation']) { printf("[009] Known bug, collation instead of chatset returned, http://bugs.mysql.com/bug.php?id=7923\n"); } else { printf("[009] Check manually, watch out for unicode and others\n"); var_dump($link_enc); var_dump($tmp); } } if (ini_get('unicode.semantics') && function_exists('is_unicode')) { // unicode mode if (!is_unicode($default_link_enc) || !is_unicode($link_enc)) { printf("[010] No unicode returned!\n"); var_dump($default_link_enc); var_dump($link_enc); } } mysql_close($link); if (false !== ($tmp = @mysql_client_encoding($link))) printf("[012] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_close.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_close.phpt +++ php-src/ext/mysql/tests/mysql_close.phpt --TEST-- mysql_close() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $db = 'test'; $tmp = NULL; $link = NULL; if (false !== ($tmp = @mysql_close())) printf("[001] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysql_close($link, $link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); $tmp = @mysql_close(NULL); if (false !== $tmp) printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); $tmp = mysql_close($link); if (true !== $tmp) printf("[005] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = @mysql_query("SELECT 1", $link))) printf("[006] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); print "done!\n"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_connect.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_connect.phpt +++ php-src/ext/mysql/tests/mysql_connect.phpt --TEST-- mysql_connect() --SKIPIF-- <?php require_once('skipif.inc'); ?> --FILE-- <?php include_once "connect.inc"; $tmp = NULL; $link = NULL; // mysql_connect ( [string server [, string username [, string password [, bool new_link [, int client_flags]]]]] ) if (NULL !== ($tmp = @mysql_connect($link, $link, $link, $link, $link, $link))) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); $myhost = (is_null($socket)) ? ((is_null($port)) ? $host : $host . ':' . $port) : $host . ':' . $socket; if (!$link = mysql_connect($myhost, $user, $passwd, true)) printf("[002] Cannot connect to the server using host=%s/%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $myhost, $user, $db, $port, $socket); mysql_close($link); if ($link = mysql_connect($myhost, $user . 'unknown_really', $passwd . 'non_empty', true)) printf("[003] Can connect to the server using host=%s/%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", $host, $myhost, $user . 'unknown_really', $db, $port, $socket); if (false !== $link) printf("[004] Expecting boolean/false, got %s/%s\n", gettype($link), $link); // Run the following tests without an anoynmous MySQL user and use a password for the test user! ini_set('mysql.default_socket', $socket); if (!is_resource($link = mysql_connect($host, $user, $passwd, true))) { printf("[005] Usage of mysql.default_socket failed\n") ; } else { mysql_close($link); } if (!ini_get('sql.safe_mode')) { ini_set('mysql.default_port', $port); if (!is_resource($link = mysql_connect($host, $user, $passwd, true))) { printf("[006] Usage of mysql.default_port failed\n") ; } else { mysql_close($link); } ini_set('mysql.default_password', $passwd); if (!is_resource($link = mysql_connect($myhost, $user))) { printf("[007] Usage of mysql.default_password failed\n") ; } else { mysql_close($link); } ini_set('mysql.default_user', $user); if (!is_resource($link = mysql_connect($myhost))) { printf("[008] Usage of mysql.default_user failed\n"); } else { mysql_close($link); } ini_set('mysql.default_host', $myhost); if (!is_resource($link = mysql_connect())) { printf("[009] Usage of mysql.default_host failed\n") ; } else { mysql_close($link); } } print "done!"; ?> --EXPECTF-- Warning: mysql_connect(): Access denied for user '%s'@'%s' (using password: YES) in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_create_db.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_create_db.phpt +++ php-src/ext/mysql/tests/mysql_create_db.phpt --TEST-- mysql_create_db() --SKIPIF-- <?php require_once('skipif.inc'); if (!function_exists('mysql_create_db')) die("Skip mysql_create_db() exists only in old versions of the libmysql."); ?> --FILE-- <?php include "connect.inc"; $link = NULL; $tmp = null; if (false !== ($tmp = mysql_create_db())) printf("[001] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysql_create_db($link, $link, $link))) printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if ($link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) printf("[003] 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); if (!mysql_query("CREATE DATABASE mysqlcreatedb", $link)) die(sprintf("[004] Cannot create database, aborting test, [%d] %s\n", mysql_errno($link), mysql_error($link))); if (!mysql_query("DROP DATABASE mysqlcreatedb", $link)) printf("[005] [%d] %s\n", mysql_errno($link), mysql_error($link)); if (true !== ($tmp = mysql_create_db("mysqlcreatedb", $link))) printf("[006] Expecting boolean/true, got %s/%s, [%d] %s\n", gettype($tmp), $tmp, mysql_errno($link), mysql_error($link)); if (false !== ($tmp = mysql_create_db("mysqlcreatedb", $link))) printf("[007] Expecting boolean/false, got %s/%s, [%d] %s\n", gettype($tmp), $tmp, mysql_errno($link), mysql_error($link)); if (!mysql_query("DROP DATABASE mysqlcreatedb", $link)) printf("[008] [%d] %s\n", mysql_errno($link), mysql_error($link)); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_data_seek.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_data_seek.phpt +++ php-src/ext/mysql/tests/mysql_data_seek.phpt --TEST-- mysql_data_seek() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (NULL !== ($tmp = @mysql_data_seek())) printf("[001] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysql_data_seek($link))) printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = @mysql_data_seek($link, $link))) printf("[003] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysql_query('SELECT * FROM test ORDER BY id LIMIT 4', $link)) printf("[004] [%d] %s\n", mysql_errno($link), mysql_error($link)); if (true !== ($tmp = mysql_data_seek($res, 3))) printf("[005] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); $row = mysql_fetch_assoc($res); if (4 != $row['id']) printf("[006] Expecting record 4/d, got record %s/%s\n", $row['id'], $row['label']); if (true !== ($tmp = mysql_data_seek($res, 0))) printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); $row = mysql_fetch_assoc($res); if (1 != $row['id']) printf("[008] Expecting record 1/a, got record %s/%s\n", $row['id'], $row['label']); if (false !== ($tmp = mysql_data_seek($res, 4))) printf("[009] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysql_data_seek($res, -1))) printf("[010] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); mysql_free_result($res); if (!$res = mysql_unbuffered_query('SELECT * FROM test ORDER BY id', $link)) printf("[011] [%d] %s\n", mysql_errno($link), mysql_error($link)); if (false !== ($tmp = mysql_data_seek($res, 3))) printf("[012] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); mysql_free_result($res); if (false !== ($tmp = mysql_data_seek($res, 1))) printf("[013] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); mysql_close($link); print "done!\n"; ?> --EXPECTF-- Warning: mysql_data_seek(): Offset 4 is invalid for MySQL result index %d (or the query data is unbuffered) in %s on line %d Warning: mysql_data_seek(): Offset -1 is invalid for MySQL result index %d (or the query data is unbuffered) in %s on line %d Warning: mysql_data_seek(): Offset 3 is invalid for MySQL result index %d (or the query data is unbuffered) in %s on line %d Warning: mysql_data_seek(): %d is not a valid MySQL result resource in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_db_name.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_db_name.phpt +++ php-src/ext/mysql/tests/mysql_db_name.phpt --TEST-- mysql_db_name() --SKIPIF-- <?php require_once('skipif.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (NULL !== ($tmp = @mysql_db_name())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = @mysql_db_name($link, $link))) printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysql_list_dbs($link)) printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link)); if (!$num = mysql_num_rows($res)) printf("[004] Empty database list? [%d] %s\n", mysql_errno($link), mysql_error($link)); if (false !== ($tmp = mysql_db_name($res, -1))) printf("[005] Expecting boolean/false, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysql_errno($link), mysql_error($link)); if (false !== ($tmp = mysql_db_name($res, $num + 1))) printf("[006] Expecting boolean/false, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysql_errno($link), mysql_error($link)); $unicode = (boolean)ini_get('unicode.semantics'); for ($i = 0; $i < $num; $i++) { if ('' === ($dbname = mysql_db_name($res, $i))) printf("[%03d] Got empty database name! [%d] %s\n", (($i * 2) + 1) + 6, mysql_errno($link), mysql_error($link)); if ($unicode && !is_unicode($dbname)) { printf("[%03d] Expecting unicode string! [%d] %s\n", (($i * 2) + 2) + 6, mysql_errno($link), mysql_error($link)); var_inspect($dbname); } } mysql_free_result($res); if (false !== ($tmp = mysql_db_name($res, $num))) printf("[999] Expecting boolean/false, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysql_errno($link), mysql_error($link)); mysql_close($link); print "done!\n"; ?> --EXPECTF-- Warning: mysql_db_name(): Unable to jump to row -1 on MySQL result index %d in %s on line %d Warning: mysql_db_name(): Unable to jump to row %d on MySQL result index %d in %s on line %d Warning: mysql_db_name(): %d is not a valid MySQL result resource in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_db_query.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_db_query.phpt +++ php-src/ext/mysql/tests/mysql_db_query.phpt --TEST-- mysql_db_query() --SKIPIF-- <?php require_once('skipif.inc'); ?> --FILE-- <?php include "connect.inc"; // NOTE: this function is deprecated. We do only the most necessary // to test it. We don't test all aspects of the documented behaviour. $tmp = NULL; $link = NULL; if (NULL !== ($tmp = @mysql_db_query())) printf("[001] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysql_db_query($link))) printf("[002] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysql_db_query($link))) printf("[003] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysql_db_query($db, 'SELECT id, label FROM test ORDER BY id LIMIT 1', $link)) printf("[004] [%d] %s\n", mysql_errno($link), mysql_error($link)); $row = mysql_fetch_assoc($res); if (1 != $row['id']) printf("[005] Expecting record 1/a, got record %s/%s\n", $row['id'], $row['label']); if (ini_get('unicode.semantics') && !is_unicode($row['label'])) { printf("[006] No unicode returned! [%d] %s\n", mysql_errno($link), mysql_error($link)); var_inspect($row); } mysql_free_result($res); mysql_close($link); print "done!\n"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_drop_db.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_drop_db.phpt +++ php-src/ext/mysql/tests/mysql_drop_db.phpt --TEST-- mysql_drop_db() --SKIPIF-- <?php require_once('skipif.inc'); if (!function_exists('mysql_drop_db')) die("Skip function is deprecated and not available"); ?> --FILE-- <?php include_once "connect.inc"; $tmp = NULL; $link = NULL; // NOTE: again this test does not test all of the behaviour of the function if (NULL !== ($tmp = mysql_drop_db())) printf("[001] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!mysql_query('DROP DATABASE IF EXISTS mysqldropdb')) printf("[004] [%d] %s\n", mysql_errno($link), mysql_error($link)); if (!mysql_query('CREATE DATABASE mysqldropdb')) die(sprintf("[005] Skipping, can't create test database. [%d] %s\n", mysql_errno($link), mysql_error($link))); if (true !== ($tmp = mysql_drop_db('mysqldropdb', $link))) printf("[006] Can't drop, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysql_errno($link), mysql_error($link)); if (false !== ($tmp = mysql_drop_db('mysqldropdb', $link))) printf("[007] Expecting boolean/false, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysql_errno($link), mysql_error($link)); mysql_close($link); print "done!\n"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_errno.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_errno.phpt +++ php-src/ext/mysql/tests/mysql_errno.phpt --TEST-- mysql_errno() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (false !== ($tmp = @mysql_errno())) printf("[001] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = @mysql_errno($link))) printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) { printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); } var_dump(mysql_errno($link)); if (!mysql_query('DROP TABLE IF EXISTS test', $link)) { printf("[004] Failed to drop old test table: [%d] %s\n", mysql_errno($link), mysql_errno($link)); } mysql_query('SELECT * FROM test', $link); var_dump(mysql_errno($link)); mysql_close($link); var_dump(mysql_errno($link)); print "done!"; ?> --EXPECTF-- int(0) int(%d) Warning: mysql_errno(): %d is not a valid MySQL-Link resource in %s on line %d bool(false) done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_error.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_error.phpt +++ php-src/ext/mysql/tests/mysql_error.phpt --TEST-- mysql_error() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (false !== ($tmp = @mysql_error())) printf("[001] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = @mysql_error($link))) printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) { printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); } $tmp = mysql_error($link); if (!is_string($tmp) || ('' !== $tmp)) printf("[004] Expecting string/empty, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysql_errno($link), mysql_error($link)); if (!mysql_query('DROP TABLE IF EXISTS test', $link)) { printf("[005] Failed to drop old test table: [%d] %s\n", mysql_errno($link), mysql_error($link)); } mysql_query('SELECT * FROM test', $link); $tmp = mysql_error($link); if (!is_string($tmp) || !preg_match("/Table '\w*\.test' doesn't exist/su", $tmp)) printf("[006] Expecting string/[Table... doesn't exit], got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysql_errno($link), mysql_error($link)); if (ini_get('unicode.semantics') && !is_unicode($tmp)) { printf("[007] Expecting Unicode error message!\n"); var_inspect($tmp); } mysql_close($link); var_dump(mysql_error($link)); print "done!"; ?> --EXPECTF-- Warning: mysql_error(): %d is not a valid MySQL-Link resource in %s on line %d bool(false) done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_escape_string.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_escape_string.phpt +++ php-src/ext/mysql/tests/mysql_escape_string.phpt --TEST-- mysql_escape_string() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $dbname = 'test'; $tmp = NULL; $link = NULL; if (NULL !== ($tmp = @mysql_escape_string())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); var_dump(mysql_escape_string("Am I a unicode string in PHP 6?")); var_dump(mysql_escape_string('\\')); var_dump(mysql_escape_string('"')); var_dump(mysql_escape_string("'")); var_dump(mysql_escape_string("\n")); var_dump(mysql_escape_string("\r")); var_dump(mysql_escape_string("foo" . chr(0) . "bar")); print "done!"; ?> --EXPECTF-- string(31) "Am I a unicode string in PHP 6?" string(2) "\\" string(2) "\"" string(2) "\'" string(2) "\n" string(2) "\r" string(8) "foo\0bar" done! --UEXPECTF-- unicode(31) "Am I a unicode string in PHP 6?" unicode(2) "\\" unicode(2) "\"" unicode(2) "\'" unicode(2) "\n" unicode(2) "\r" unicode(8) "foo\0bar" done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_fetch_array.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_fetch_array.phpt +++ php-src/ext/mysql/tests/mysql_fetch_array.phpt --TEST-- mysql_fetch_array() --SKIPIF-- <?php require_once('skipif.inc'); ?> --FILE-- <?php include_once "connect.inc"; $tmp = NULL; $link = NULL; if (NULL !== ($tmp = @mysql_fetch_array())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = @mysql_fetch_array($link))) printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysql_query("SELECT * FROM test ORDER BY id LIMIT 5", $link)) { printf("[004] [%d] %s\n", mysql_errno($link), mysql_error($link)); } print "[005]\n"; var_dump(mysql_fetch_array($res)); print "[006]\n"; var_dump(mysql_fetch_array($res, MYSQL_NUM)); print "[007]\n"; var_dump(mysql_fetch_array($res, MYSQL_BOTH)); print "[008]\n"; var_dump(mysql_fetch_array($res, MYSQL_ASSOC)); print "[009]\n"; var_dump(mysql_fetch_array($res)); mysql_free_result($res); if (!$res = mysql_query("SELECT 1 AS a, 2 AS a, 3 AS c, 4 AS C, NULL AS d, true AS e", $link)) { printf("[010] Cannot run query, [%d] %s\n", mysql_errno($link), mysql_error($link)); } print "[011]\n"; var_dump(mysql_fetch_array($res, MYSQL_BOTH)); mysql_free_result($res); if (!$res = mysql_query("SELECT 1 AS a, 2 AS b, 3 AS c, 4 AS C", $link)) { printf("[012] Cannot run query, [%d] %s\n", mysql_errno($link), $mysql_error($link)); exit(1); } do { $illegal_mode = mt_rand(0, 10000); } while (in_array($illegal_mode, array(MYSQL_ASSOC, MYSQL_NUM, MYSQL_BOTH))); $tmp = @mysql_fetch_array($res, $illegal_mode); if (!is_array($tmp)) printf("[013] Expecting array, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysql_errno($link), mysql_error($link)); $tmp = @mysql_fetch_array($res, $illegal_mode); if (false !== $tmp) printf("[014] Expecting boolean/false, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysql_errno($link), mysql_error($link)); mysql_free_result($res); function func_mysql_fetch_array($link, $engine, $sql_type, $sql_value, $php_value, $offset, $regexp_comparison = NULL) { if (!mysql_query("DROP TABLE IF EXISTS test", $link)) { printf("[%04d] [%d] %s\n", $offset, mysql_errno($link), mysql_error($link)); return false; } if (!mysql_query($sql = sprintf("CREATE TABLE test(id INT NOT NULL, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine), $link)) { print $sql; // don't bail, engine might not support the datatype return false; } if (is_null($php_value) && !mysql_query($sql = sprintf("INSERT INTO test(id, label) VALUES (1, NULL)"), $link)) { printf("[%04d] [%d] %s\n", $offset + 1, mysql_errno($link), mysql_error($link)); return false; } if (!is_null($php_value)) { if (is_int($sql_value) && !mysql_query(sprintf("INSERT INTO test(id, label) VALUES (1, '%d')", $sql_value), $link)) { printf("[%04d] [%d] %s\n", $offset + 1, mysql_errno($link), mysql_error($link)); return false; } else if (!is_int($sql_value) && !mysql_query(sprintf("INSERT INTO test(id, label) VALUES (1, '%s')", $sql_value), $link)) { printf("[%04d] [%d] %s\n", $offset + 1, mysql_errno($link), mysql_error($link)); return false; } } if (!$res = mysql_query("SELECT id, label FROM test", $link)) { printf("[%04d] [%d] %s\n", $offset + 2, mysql_errno($link), mysql_error($link)); return false; } if (!$row = mysql_fetch_array($res, MYSQL_BOTH)) { printf("[%04d] [%d] %s\n", $offset + 3, mysql_errno($link), mysql_error($link)); return false; } if ($regexp_comparison) { if (!preg_match($regexp_comparison, (string)$row['label']) || !preg_match($regexp_comparison, (string)$row[1])) { printf("[%04d] Expecting %s/%s [reg exp = %s], got %s/%s resp. %s/%s. [%d] %s\n", $offset + 4, gettype($php_value), $php_value, $regexp_comparison, gettype($row[1]), $row[1], gettype($row['label']), $row['label'], mysql_errno($link), mysql_error($link)); return false; } } else { if (($row['label'] !== $php_value) || ($row[1] != $php_value)) { printf("[%04d] Expecting %s/%s, got %s/%s resp. %s/%s. [%d] %s\n", $offset + 4, gettype($php_value), $php_value, gettype($row[1]), $row[1], gettype($row['label']), $row['label'], mysql_errno($link), mysql_error($link)); return false; } } if (ini_get('unicode.semantics') && !is_unicode($row['label']) && !is_null($row['label'])) { printf("[%04d] Expecting Unicode\n", $offset + 5); var_inspect($row['label']); } return true; } function func_mysql_fetch_array_make_string($len) { $ret = ''; for ($i = 0; $i < $len; $i++) $ret .= chr(mt_rand(65, 90)); return $ret; } func_mysql_fetch_array($link, $engine, "TINYINT", -11, "-11", 20); func_mysql_fetch_array($link, $engine, "TINYINT", NULL, NULL, 30); func_mysql_fetch_array($link, $engine, "TINYINT UNSIGNED", 1, "1", 40); func_mysql_fetch_array($link, $engine, "TINYINT UNSIGNED", NULL, NULL, 50); func_mysql_fetch_array($link, $engine, "BOOL", 1, "1", 60); func_mysql_fetch_array($link, $engine, "BOOL", NULL, NULL, 70); func_mysql_fetch_array($link, $engine, "BOOLEAN", 0, "0", 80); func_mysql_fetch_array($link, $engine, "BOOLEAN", NULL, NULL, 90); func_mysql_fetch_array($link, $engine, "SMALLINT", -32768, "-32768", 100); func_mysql_fetch_array($link, $engine, "SMALLINT", 32767, "32767", 110); func_mysql_fetch_array($link, $engine, "SMALLINT", NULL, NULL, 120); func_mysql_fetch_array($link, $engine, "SMALLINT UNSIGNED", 65535, "65535", 130); func_mysql_fetch_array($link, $engine, "SMALLINT UNSIGNED", NULL, NULL, 140); func_mysql_fetch_array($link, $engine, "MEDIUMINT", -8388608, "-8388608", 150); func_mysql_fetch_array($link, $engine, "MEDIUMINT", 8388607, "8388607", 160); func_mysql_fetch_array($link, $engine, "MEDIUMINT", NULL, NULL, 170); func_mysql_fetch_array($link, $engine, "MEDIUMINT UNSIGNED", 16777215, "16777215", 180); func_mysql_fetch_array($link, $engine, "MEDIUMINT UNSIGNED", NULL, NULL, 190); func_mysql_fetch_array($link, $engine, "INTEGER", -2147483648, "-2147483648", 200); func_mysql_fetch_array($link, $engine, "INTEGER", 2147483647, "2147483647", 210); func_mysql_fetch_array($link, $engine, "INTEGER", NULL, NULL, 220); func_mysql_fetch_array($link, $engine, "INTEGER UNSIGNED", 4294967295, "4294967295", 230); func_mysql_fetch_array($link, $engine, "INTEGER UNSIGNED", NULL, NULL, 240); // func_mysql_fetch_array($link, $engine, "BIGINT", -9223372036854775808, "-9.22337e+018", 250, "/-9\.22337e\+[0]?18/iu"); func_mysql_fetch_array($link, $engine, "BIGINT", NULL, NULL, 260); // func_mysql_fetch_array($link, $engine, "BIGINT UNSIGNED", 18446744073709551615, "1.84467e+019", 270, "/1\.84467e\+[0]?19/iu"); func_mysql_fetch_array($link, $engine, "BIGINT UNSIGNED", NULL, NULL, 280); func_mysql_fetch_array($link, $engine, "FLOAT", -9223372036854775808 - 1.1, "-9.22337e+18", 290, "/-9\.22337e\+[0]?18/iu"); func_mysql_fetch_array($link, $engine, "FLOAT", NULL, NULL, 300); func_mysql_fetch_array($link, $engine, "FLOAT UNSIGNED", 18446744073709551615 + 1.1, "1.84467e+19", 310, "/1\.84467e\+[0]?19/iu"); func_mysql_fetch_array($link, $engine, "FLOAT UNSIGNED ", NULL, NULL, 320); func_mysql_fetch_array($link, $engine, "DOUBLE(10,2)", -99999999.99, "-99999999.99", 330); func_mysql_fetch_array($link, $engine, "DOUBLE(10,2)", NULL, NULL, 340); func_mysql_fetch_array($link, $engine, "DOUBLE(10,2) UNSIGNED", 99999999.99, "99999999.99", 350); func_mysql_fetch_array($link, $engine, "DOUBLE(10,2) UNSIGNED", NULL, NULL, 360); func_mysql_fetch_array($link, $engine, "DECIMAL(10,2)", -99999999.99, "-99999999.99", 370); func_mysql_fetch_array($link, $engine, "DECIMAL(10,2)", NULL, NULL, 380); func_mysql_fetch_array($link, $engine, "DECIMAL(10,2)", 99999999.99, "99999999.99", 390); func_mysql_fetch_array($link, $engine, "DECIMAL(10,2)", NULL, NULL, 400); // don't care about date() strict TZ warnings... func_mysql_fetch_array($link, $engine, "DATE", @date('Y-m-d'), @date('Y-m-d'), 410); func_mysql_fetch_array($link, $engine, "DATE NOT NULL", @date('Y-m-d'), @date('Y-m-d'), 420); func_mysql_fetch_array($link, $engine, "DATE", NULL, NULL, 430); func_mysql_fetch_array($link, $engine, "DATETIME", @date('Y-m-d H:i:s'), @date('Y-m-d H:i:s'), 440); func_mysql_fetch_array($link, $engine, "DATETIME NOT NULL", @date('Y-m-d H:i:s'), @date('Y-m-d H:i:s'), 450); func_mysql_fetch_array($link, $engine, "DATETIME", NULL, NULL, 460); func_mysql_fetch_array($link, $engine, "TIMESTAMP", @date('Y-m-d H:i:s'), @date('Y-m-d H:i:s'), 470); func_mysql_fetch_array($link, $engine, "TIME", @date('H:i:s'), @date('H:i:s'), 480); func_mysql_fetch_array($link, $engine, "TIME NOT NULL", @date('H:i:s'), @date('H:i:s'), 490); func_mysql_fetch_array($link, $engine, "TIME", NULL, NULL, 500); func_mysql_fetch_array($link, $engine, "YEAR", @date('Y'), @date('Y'), 510); func_mysql_fetch_array($link, $engine, "YEAR NOT NULL", @date('Y'), @date('Y'), 520); func_mysql_fetch_array($link, $engine, "YEAR", NULL, NULL, 530); $string255 = func_mysql_fetch_array_make_string(255); func_mysql_fetch_array($link, $engine, "CHAR(1)", "a", "a", 540); func_mysql_fetch_array($link, $engine, "CHAR(255)", $string255, $string255, 550); func_mysql_fetch_array($link, $engine, "CHAR(1) NOT NULL", "a", "a", 560); func_mysql_fetch_array($link, $engine, "CHAR(1)", NULL, NULL, 570); $string65k = func_mysql_fetch_array_make_string(65535); func_mysql_fetch_array($link, $engine, "VARCHAR(1)", "a", "a", 580); func_mysql_fetch_array($link, $engine, "VARCHAR(255)", $string255, $string255, 590); func_mysql_fetch_array($link, $engine, "VARCHAR(65635)", $string65k, $string65k, 600); func_mysql_fetch_array($link, $engine, "VARCHAR(1) NOT NULL", "a", "a", 610); func_mysql_fetch_array($link, $engine, "VARCHAR(1)", NULL, NULL, 620); func_mysql_fetch_array($link, $engine, "BINARY(1)", "a", "a", 630); func_mysql_fetch_array($link, $engine, "BINARY(1) NOT NULL", "b", "b", 650); func_mysql_fetch_array($link, $engine, "BINARY(1)", NULL, NULL, 660); func_mysql_fetch_array($link, $engine, "VARBINARY(1)", "a", "a", 670); func_mysql_fetch_array($link, $engine, "VARBINARY(1) NOT NULL", "b", "b", 690); func_mysql_fetch_array($link, $engine, "VARBINARY(1)", NULL, NULL, 700); func_mysql_fetch_array($link, $engine, "TINYBLOB", "a", "a", 710); func_mysql_fetch_array($link, $engine, "TINYBLOB NOT NULL", "b", "b", 730); func_mysql_fetch_array($link, $engine, "TINYBLOB", NULL, NULL, 740); func_mysql_fetch_array($link, $engine, "TINYTEXT", "a", "a", 750); func_mysql_fetch_array($link, $engine, "TINYTEXT NOT NULL", "a", "a", 760); func_mysql_fetch_array($link, $engine, "TINYTEXT", NULL, NULL, 770); func_mysql_fetch_array($link, $engine, "BLOB", "a", "a", 780); func_mysql_fetch_array($link, $engine, "BLOB", NULL, NULL, 790); func_mysql_fetch_array($link, $engine, "TEXT", "a", "a", 800); func_mysql_fetch_array($link, $engine, "TEXT", NULL, NULL, 820); func_mysql_fetch_array($link, $engine, "MEDIUMBLOB", "a", "a", 830); func_mysql_fetch_array($link, $engine, "MEDIUMBLOB", NULL, NULL, 850); func_mysql_fetch_array($link, $engine, "MEDIUMTEXT", "a", "a", 860); func_mysql_fetch_array($link, $engine, "MEDIUMTEXT", NULL, NULL, 880); func_mysql_fetch_array($link, $engine, "LONGBLOB", "a", "a", 890); func_mysql_fetch_array($link, $engine, "LONGBLOB", NULL, NULL, 910); func_mysql_fetch_array($link, $engine, "ENUM('a', 'b')", "a", "a", 920); func_mysql_fetch_array($link, $engine, "ENUM('a', 'b')", NULL, NULL, 930); func_mysql_fetch_array($link, $engine, "SET('a', 'b')", "a", "a", 940); func_mysql_fetch_array($link, $engine, "SET('a', 'b')", NULL, NULL, 950); mysql_close($link); if (false !== ($tmp = mysql_fetch_array($res, MYSQL_ASSOC))) printf("[015] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- [005] array(4) { [0]=> string(1) "1" ["id"]=> string(1) "1" [1]=> string(1) "a" ["label"]=> string(1) "a" } [006] array(2) { [0]=> string(1) "2" [1]=> string(1) "b" } [007] array(4) { [0]=> string(1) "3" ["id"]=> string(1) "3" [1]=> string(1) "c" ["label"]=> string(1) "c" } [008] array(2) { ["id"]=> string(1) "4" ["label"]=> string(1) "d" } [009] array(4) { [0]=> string(1) "5" ["id"]=> string(1) "5" [1]=> string(1) "e" ["label"]=> string(1) "e" } [011] array(11) { [0]=> string(1) "1" ["a"]=> string(1) "2" [1]=> string(1) "2" [2]=> string(1) "3" ["c"]=> string(1) "3" [3]=> string(1) "4" ["C"]=> string(1) "4" [4]=> NULL ["d"]=> NULL [5]=> string(1) "1" ["e"]=> string(1) "1" } Warning: mysql_fetch_array(): %d is not a valid MySQL result resource in %s on line %d done! --UEXPECTF-- [005] array(4) { [0]=> unicode(1) "1" [u"id"]=> unicode(1) "1" [1]=> unicode(1) "a" [u"label"]=> unicode(1) "a" } [006] array(2) { [0]=> unicode(1) "2" [1]=> unicode(1) "b" } [007] array(4) { [0]=> unicode(1) "3" [u"id"]=> unicode(1) "3" [1]=> unicode(1) "c" [u"label"]=> unicode(1) "c" } [008] array(2) { [u"id"]=> unicode(1) "4" [u"label"]=> unicode(1) "d" } [009] array(4) { [0]=> unicode(1) "5" [u"id"]=> unicode(1) "5" [1]=> unicode(1) "e" [u"label"]=> unicode(1) "e" } [011] array(11) { [0]=> unicode(1) "1" [u"a"]=> unicode(1) "2" [1]=> unicode(1) "2" [2]=> unicode(1) "3" [u"c"]=> unicode(1) "3" [3]=> unicode(1) "4" [u"C"]=> unicode(1) "4" [4]=> NULL [u"d"]=> NULL [5]=> unicode(1) "1" [u"e"]=> unicode(1) "1" } Warning: mysql_fetch_array(): %d is not a valid MySQL result resource in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_fetch_assoc.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_fetch_assoc.phpt +++ php-src/ext/mysql/tests/mysql_fetch_assoc.phpt --TEST-- mysql_fetch_assoc() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; // Note: no SQL type tests, internally the same function gets used as for mysql_fetch_array() which does a lot of SQL type test if (!is_null($tmp = @mysql_fetch_assoc())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = @mysql_fetch_assoc($link))) printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysql_query("SELECT id, label FROM test ORDER BY id LIMIT 1", $link)) { printf("[004] [%d] %s\n", mysql_errno($link), mysql_error($link)); } print "[005]\n"; var_dump(mysql_fetch_assoc($res)); print "[006]\n"; var_dump(mysql_fetch_assoc($res)); mysql_free_result($res); if (!$res = mysql_query("SELECT 1 AS a, 2 AS a, 3 AS c, 4 AS C, NULL AS d, true AS e", $link)) { printf("[007] Cannot run query, [%d] %s\n", mysql_errno($link), $mysql_error($link)); } print "[008]\n"; var_dump(mysql_fetch_assoc($res)); mysql_free_result($res); if (false !== ($tmp = mysql_fetch_assoc($res))) printf("[008] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); mysql_close($link); print "done!"; ?> --EXPECTF-- [005] array(2) { ["id"]=> string(1) "1" ["label"]=> string(1) "a" } [006] bool(false) [008] array(5) { ["a"]=> string(1) "2" ["c"]=> string(1) "3" ["C"]=> string(1) "4" ["d"]=> NULL ["e"]=> string(1) "1" } Warning: mysql_fetch_assoc(): %d is not a valid MySQL result resource in %s on line %d done! --UEXPECTF-- [005] array(2) { [u"id"]=> unicode(1) "1" [u"label"]=> unicode(1) "a" } [006] bool(false) [008] array(5) { [u"a"]=> unicode(1) "2" [u"c"]=> unicode(1) "3" [u"C"]=> unicode(1) "4" [u"d"]=> NULL [u"e"]=> unicode(1) "1" } Warning: mysql_fetch_assoc(): %d is not a valid MySQL result resource in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_fetch_field.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_fetch_field.phpt +++ php-src/ext/mysql/tests/mysql_fetch_field.phpt --TEST-- mysql_fetch_field() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; // Note: no SQL type tests, internally the same function gets used as for mysql_fetch_array() which does a lot of SQL type test if (!is_null($tmp = @mysql_fetch_field())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = @mysql_fetch_field($link))) printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysql_query("SELECT id AS ID, label FROM test AS TEST ORDER BY id LIMIT 1", $link)) { printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link)); } while ($tmp = mysql_fetch_field($res)) var_dump($tmp); var_dump($tmp); mysql_free_result($res); if (false !== ($tmp = mysql_fetch_field($res))) printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); mysql_close($link); print "done!"; ?> --EXPECTF-- object(stdClass)#%d (13) { ["name"]=> string(2) "ID" ["table"]=> string(4) "TEST" ["def"]=> string(0) "" ["max_length"]=> int(1) ["not_null"]=> int(1) ["primary_key"]=> int(1) ["multiple_key"]=> int(0) ["unique_key"]=> int(0) ["numeric"]=> int(1) ["blob"]=> int(0) ["type"]=> string(3) "int" ["unsigned"]=> int(0) ["zerofill"]=> int(0) } object(stdClass)#%d (13) { ["name"]=> string(5) "label" ["table"]=> string(4) "TEST" ["def"]=> string(0) "" ["max_length"]=> int(1) ["not_null"]=> int(0) ["primary_key"]=> int(0) ["multiple_key"]=> int(0) ["unique_key"]=> int(0) ["numeric"]=> int(0) ["blob"]=> int(0) ["type"]=> string(6) "string" ["unsigned"]=> int(0) ["zerofill"]=> int(0) } bool(false) Warning: mysql_fetch_field(): %d is not a valid MySQL result resource in %s on line %d done! --UEXPECTF-- object(stdClass)#%d (13) { [u"name"]=> unicode(2) "ID" [u"table"]=> unicode(4) "TEST" [u"def"]=> unicode(0) "" [u"max_length"]=> int(1) [u"not_null"]=> int(1) [u"primary_key"]=> int(1) [u"multiple_key"]=> int(0) [u"unique_key"]=> int(0) [u"numeric"]=> int(1) [u"blob"]=> int(0) [u"type"]=> unicode(3) "int" [u"unsigned"]=> int(0) [u"zerofill"]=> int(0) } object(stdClass)#%d (13) { [u"name"]=> unicode(5) "label" [u"table"]=> unicode(4) "TEST" [u"def"]=> unicode(0) "" [u"max_length"]=> int(1) [u"not_null"]=> int(0) [u"primary_key"]=> int(0) [u"multiple_key"]=> int(0) [u"unique_key"]=> int(0) [u"numeric"]=> int(0) [u"blob"]=> int(0) [u"type"]=> unicode(6) "string" [u"unsigned"]=> int(0) [u"zerofill"]=> int(0) } bool(false) Warning: mysql_fetch_field(): %d is not a valid MySQL result resource in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_fetch_lengths.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_fetch_lengths.phpt +++ php-src/ext/mysql/tests/mysql_fetch_lengths.phpt --TEST-- mysql_fetch_lengths() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysql_fetch_lengths())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = @mysql_fetch_lengths($link))) printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysql_query("SELECT id, label FROM test ORDER BY id LIMIT 1", $link)) { printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link)); } while ($row = mysql_fetch_assoc($res)) var_dump(mysql_fetch_lengths($res)); var_dump(mysql_fetch_lengths($res)); mysql_free_result($res); var_dump(mysql_fetch_lengths($res)); mysql_close($link); print "done!"; ?> --EXPECTF-- array(2) { [0]=> int(1) [1]=> int(1) } bool(false) Warning: mysql_fetch_lengths(): %d is not a valid MySQL result resource in %s on line %d bool(false) done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_fetch_object.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_fetch_object.phpt +++ php-src/ext/mysql/tests/mysql_fetch_object.phpt --TEST-- mysql_fetch_object() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysql_fetch_object())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = @mysql_fetch_object($link))) printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysql_query("SELECT id AS ID, label FROM test AS TEST ORDER BY id LIMIT 5", $link)) { printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link)); } var_dump(mysql_fetch_object($res)); class mysql_fetch_object_test { public $a = null; public $b = null; public function toString() { var_dump($this); } } var_dump(mysql_fetch_object($res, 'mysql_fetch_object_test')); class mysql_fetch_object_construct extends mysql_fetch_object_test { public function __construct($a, $b) { $this->a = $a; $this->b = $b; } } var_dump(mysql_fetch_object($res, 'mysql_fetch_object_construct', null)); var_dump(mysql_fetch_object($res, 'mysql_fetch_object_construct', array('a'))); var_dump(mysql_fetch_object($res, 'mysql_fetch_object_construct', array('a', 'b'))); var_dump(mysql_fetch_object($res, 'mysql_fetch_object_construct', array('a', 'b', 'c'))); var_dump(mysql_fetch_object($res)); mysql_free_result($res); if (!$res = mysql_query("SELECT id AS ID, label FROM test AS TEST", $link)) { printf("[009] [%d] %s\n", mysql_errno($link), mysql_error($link)); } mysql_free_result($res); var_dump(mysql_fetch_object($res)); // Fatal error, script execution will end var_dump(mysql_fetch_object($res, 'this_class_does_not_exist')); mysql_close($link); print "done!"; ?> --EXPECTF-- object(stdClass)#%d (2) { ["ID"]=> string(1) "1" ["label"]=> string(1) "a" } object(mysql_fetch_object_test)#%d (4) { ["a"]=> NULL ["b"]=> NULL ["ID"]=> string(1) "2" ["label"]=> string(1) "b" } Warning: Missing argument 1 for mysql_fetch_object_construct::__construct() in %s on line %d Warning: Missing argument 2 for mysql_fetch_object_construct::__construct() in %s on line %d Notice: Undefined variable: a in %s on line %d Notice: Undefined variable: b in %s on line %d object(mysql_fetch_object_construct)#1 (4) { ["a"]=> NULL ["b"]=> NULL ["ID"]=> string(1) "3" ["label"]=> string(1) "c" } Warning: Missing argument 2 for mysql_fetch_object_construct::__construct() in %s on line %d Notice: Undefined variable: b in %s on line %d object(mysql_fetch_object_construct)#1 (4) { ["a"]=> string(1) "a" ["b"]=> NULL ["ID"]=> string(1) "4" ["label"]=> string(1) "d" } object(mysql_fetch_object_construct)#1 (4) { ["a"]=> string(1) "a" ["b"]=> string(1) "b" ["ID"]=> string(1) "5" ["label"]=> string(1) "e" } bool(false) bool(false) Warning: mysql_fetch_object(): %d is not a valid MySQL result resource in %s on line %d bool(false) Fatal error: Class 'this_class_does_not_exist' not found in %s on line %d --UEXPECTF-- object(stdClass)#%d (2) { [u"ID"]=> unicode(1) "1" [u"label"]=> unicode(1) "a" } object(mysql_fetch_object_test)#%d (4) { [u"a"]=> NULL [u"b"]=> NULL [u"ID"]=> unicode(1) "2" [u"label"]=> unicode(1) "b" } Warning: Missing argument 1 for mysql_fetch_object_construct::__construct() in %s on line %d Warning: Missing argument 2 for mysql_fetch_object_construct::__construct() in %s on line %d Notice: Undefined variable: a in %s on line %d Notice: Undefined variable: b in %s on line %d object(mysql_fetch_object_construct)#1 (4) { [u"a"]=> NULL [u"b"]=> NULL [u"ID"]=> unicode(1) "3" [u"label"]=> unicode(1) "c" } Warning: Missing argument 2 for mysql_fetch_object_construct::__construct() in %s on line %d Notice: Undefined variable: b in %s on line %d object(mysql_fetch_object_construct)#1 (4) { [u"a"]=> unicode(1) "a" [u"b"]=> NULL [u"ID"]=> unicode(1) "4" [u"label"]=> unicode(1) "d" } object(mysql_fetch_object_construct)#1 (4) { [u"a"]=> unicode(1) "a" [u"b"]=> unicode(1) "b" [u"ID"]=> unicode(1) "5" [u"label"]=> unicode(1) "e" } bool(false) bool(false) Warning: mysql_fetch_object(): %d is not a valid MySQL result resource in %s on line %d bool(false) Fatal error: Class 'this_class_does_not_exist' not found in %s on line %d http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_fetch_row.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_fetch_row.phpt +++ php-src/ext/mysql/tests/mysql_fetch_row.phpt --TEST-- mysql_fetch_row() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysql_fetch_row())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = @mysql_fetch_row($link))) printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysql_query("SELECT id, label FROM test ORDER BY id LIMIT 1", $link)) { printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link)); } print "[004]\n"; var_dump(mysql_fetch_row($res)); print "[005]\n"; var_dump(mysql_fetch_row($res)); mysql_free_result($res); var_dump(mysql_fetch_row($res)); mysql_close($link); print "done!"; ?> --EXPECTF-- [004] array(2) { [0]=> string(1) "1" [1]=> string(1) "a" } [005] bool(false) Warning: mysql_fetch_row(): %d is not a valid MySQL result resource in %s on line %d bool(false) done! --EXPECTF-- [004] array(2) { [0]=> string(1) "1" [1]=> string(1) "a" } [005] bool(false) Warning: mysql_fetch_row(): %d is not a valid MySQL result resource in %s on line %d bool(false) done! --UEXPECTF-- [004] array(2) { [0]=> unicode(1) "1" [1]=> unicode(1) "a" } [005] bool(false) Warning: mysql_fetch_row(): %d is not a valid MySQL result resource in %s on line %d bool(false) done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_field_flags.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_field_flags.phpt +++ php-src/ext/mysql/tests/mysql_field_flags.phpt --TEST-- mysql_field_flags() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysql_field_flags())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (null !== ($tmp = @mysql_field_flags($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysql_query("SELECT id, label FROM test ORDER BY id LIMIT 2", $link)) { printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link)); } if (NULL !== ($tmp = mysql_field_flags($res))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysql_field_flags($res, -1))) printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (!is_string($tmp = mysql_field_flags($res, 0)) || empty($tmp)) printf("[006] Expecting non empty string, got %s/%s\n", gettype($tmp), $tmp); if (ini_get('unicode.semantics') && !is_unicode($tmp)) { printf("[007] Check the unicode support!\n"); var_inspect($tmp); } if (false !== ($tmp = mysql_field_flags($res, 2))) printf("[008] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); mysql_free_result($res); var_dump(mysql_field_flags($res, 0)); mysql_close($link); print "done!"; ?> --EXPECTF-- Warning: Wrong parameter count for mysql_field_flags() in %s on line %d Warning: mysql_field_flags(): Field -1 is invalid for MySQL result index %d in %s on line %d Warning: mysql_field_flags(): Field 2 is invalid for MySQL result index %d in %s on line %d Warning: mysql_field_flags(): %d is not a valid MySQL result resource in %s on line %d bool(false) done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_field_len.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_field_len.phpt +++ php-src/ext/mysql/tests/mysql_field_len.phpt --TEST-- mysql_field_len() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysql_field_len())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (null !== ($tmp = @mysql_field_len($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysql_query("SELECT id, label FROM test ORDER BY id LIMIT 2", $link)) { printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link)); } if (NULL !== ($tmp = mysql_field_len($res))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysql_field_len($res, -1))) printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (!is_int($tmp = mysql_field_len($res, 0)) || empty($tmp)) printf("[006] Expecting non empty integer, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysql_field_len($res, 2))) printf("[008] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); mysql_free_result($res); var_dump(mysql_field_len($res, 0)); mysql_close($link); print "done!"; ?> --EXPECTF-- Warning: Wrong parameter count for mysql_field_len() in %s on line %d Warning: mysql_field_len(): Field -1 is invalid for MySQL result index %d in %s on line %d Warning: mysql_field_len(): Field 2 is invalid for MySQL result index %d in %s on line %d Warning: mysql_field_len(): %d is not a valid MySQL result resource in %s on line %d bool(false) done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_field_name.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_field_name.phpt +++ php-src/ext/mysql/tests/mysql_field_name.phpt --TEST-- mysql_field_name() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysql_field_name())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (null !== ($tmp = @mysql_field_name($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysql_query("SELECT id, label FROM test ORDER BY id LIMIT 2", $link)) { printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link)); } if (NULL !== ($tmp = mysql_field_name($res))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysql_field_name($res, -1))) printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); var_dump(mysql_field_name($res, 0)); if (false !== ($tmp = mysql_field_name($res, 2))) printf("[008] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); mysql_free_result($res); var_dump(mysql_field_name($res, 0)); mysql_close($link); print "done!"; ?> --EXPECTF-- Warning: Wrong parameter count for mysql_field_name() in %s on line %d Warning: mysql_field_name(): Field -1 is invalid for MySQL result index %d in %s on line %d string(2) "id" Warning: mysql_field_name(): Field 2 is invalid for MySQL result index %d in %s on line %d Warning: mysql_field_name(): %d is not a valid MySQL result resource in %s on line %d bool(false) done! --UEXPECTF-- Warning: Wrong parameter count for mysql_field_name() in %s on line %d Warning: mysql_field_name(): Field -1 is invalid for MySQL result index %d in %s on line %d unicode(2) "id" Warning: mysql_field_name(): Field 2 is invalid for MySQL result index %d in %s on line %d Warning: mysql_field_name(): %d is not a valid MySQL result resource in %s on line %d bool(false) done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_field_seek.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_field_seek.phpt +++ php-src/ext/mysql/tests/mysql_field_seek.phpt --TEST-- mysql_field_seek() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysql_field_seek())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysql_field_seek($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysql_query("SELECT id, label FROM test ORDER BY id LIMIT 1", $link)) { printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link)); } var_dump(mysql_field_seek($res, -1)); var_dump(mysql_fetch_field($res)); var_dump(mysql_field_seek($res, 0)); var_dump(mysql_fetch_field($res)); var_dump(mysql_field_seek($res, 1)); var_dump(mysql_fetch_field($res)); var_dump(mysql_field_seek($res, 2)); var_dump(mysql_fetch_field($res)); mysql_free_result($res); var_dump(mysql_field_seek($res, 0)); mysql_close($link); print "done!"; ?> --EXPECTF-- Warning: mysql_field_seek(): Field -1 is invalid for MySQL result index %d in %s on line %d bool(false) object(stdClass)#%d (13) { ["name"]=> string(2) "id" ["table"]=> string(4) "test" ["def"]=> string(0) "" ["max_length"]=> int(1) ["not_null"]=> int(1) ["primary_key"]=> int(1) ["multiple_key"]=> int(0) ["unique_key"]=> int(0) ["numeric"]=> int(1) ["blob"]=> int(0) ["type"]=> string(3) "int" ["unsigned"]=> int(0) ["zerofill"]=> int(0) } bool(true) object(stdClass)#%d (13) { ["name"]=> string(2) "id" ["table"]=> string(4) "test" ["def"]=> string(0) "" ["max_length"]=> int(1) ["not_null"]=> int(1) ["primary_key"]=> int(1) ["multiple_key"]=> int(0) ["unique_key"]=> int(0) ["numeric"]=> int(1) ["blob"]=> int(0) ["type"]=> string(3) "int" ["unsigned"]=> int(0) ["zerofill"]=> int(0) } bool(true) object(stdClass)#%d (13) { ["name"]=> string(5) "label" ["table"]=> string(4) "test" ["def"]=> string(0) "" ["max_length"]=> int(1) ["not_null"]=> int(0) ["primary_key"]=> int(0) ["multiple_key"]=> int(0) ["unique_key"]=> int(0) ["numeric"]=> int(0) ["blob"]=> int(0) ["type"]=> string(6) "string" ["unsigned"]=> int(0) ["zerofill"]=> int(0) } Warning: mysql_field_seek(): Field %d is invalid for MySQL result index %d in %s on line %d bool(false) bool(false) Warning: mysql_field_seek(): %d is not a valid MySQL result resource in %s on line %d bool(false) done! --UEXPECTF-- Warning: mysql_field_seek(): Field -1 is invalid for MySQL result index %d in %s on line %d bool(false) object(stdClass)#%d (13) { [u"name"]=> unicode(2) "id" [u"table"]=> unicode(4) "test" [u"def"]=> unicode(0) "" [u"max_length"]=> int(1) [u"not_null"]=> int(1) [u"primary_key"]=> int(1) [u"multiple_key"]=> int(0) [u"unique_key"]=> int(0) [u"numeric"]=> int(1) [u"blob"]=> int(0) [u"type"]=> unicode(3) "int" [u"unsigned"]=> int(0) [u"zerofill"]=> int(0) } bool(true) object(stdClass)#%d (13) { [u"name"]=> unicode(2) "id" [u"table"]=> unicode(4) "test" [u"def"]=> unicode(0) "" [u"max_length"]=> int(1) [u"not_null"]=> int(1) [u"primary_key"]=> int(1) [u"multiple_key"]=> int(0) [u"unique_key"]=> int(0) [u"numeric"]=> int(1) [u"blob"]=> int(0) [u"type"]=> unicode(3) "int" [u"unsigned"]=> int(0) [u"zerofill"]=> int(0) } bool(true) object(stdClass)#%d (13) { [u"name"]=> unicode(5) "label" [u"table"]=> unicode(4) "test" [u"def"]=> unicode(0) "" [u"max_length"]=> int(1) [u"not_null"]=> int(0) [u"primary_key"]=> int(0) [u"multiple_key"]=> int(0) [u"unique_key"]=> int(0) [u"numeric"]=> int(0) [u"blob"]=> int(0) [u"type"]=> unicode(6) "string" [u"unsigned"]=> int(0) [u"zerofill"]=> int(0) } Warning: mysql_field_seek(): Field %d is invalid for MySQL result index %d in %s on line %d bool(false) bool(false) Warning: mysql_field_seek(): %d is not a valid MySQL result resource in %s on line %d bool(false) done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_field_table.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_field_table.phpt +++ php-src/ext/mysql/tests/mysql_field_table.phpt --TEST-- mysql_field_table() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysql_field_table())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (null !== ($tmp = @mysql_field_table($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysql_query("SELECT id, label FROM test ORDER BY id LIMIT 2", $link)) { printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link)); } if (NULL !== ($tmp = mysql_field_table($res))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysql_field_table($res, -1))) printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); var_dump(mysql_field_table($res, 0)); if (false !== ($tmp = mysql_field_table($res, 2))) printf("[008] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); mysql_free_result($res); var_dump(mysql_field_table($res, 0)); mysql_close($link); print "done!"; ?> --EXPECTF-- Warning: Wrong parameter count for mysql_field_table() in %s on line %d Warning: mysql_field_table(): Field -1 is invalid for MySQL result index %d in %s on line %d string(4) "test" Warning: mysql_field_table(): Field 2 is invalid for MySQL result index %d in %s on line %d Warning: mysql_field_table(): %d is not a valid MySQL result resource in %s on line %d bool(false) done! --UEXPECTF-- Warning: Wrong parameter count for mysql_field_table() in %s on line %d Warning: mysql_field_table(): Field -1 is invalid for MySQL result index %d in %s on line %d unicode(4) "test" Warning: mysql_field_table(): Field 2 is invalid for MySQL result index %d in %s on line %d Warning: mysql_field_table(): %d is not a valid MySQL result resource in %s on line %d bool(false) done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_field_type.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_field_type.phpt +++ php-src/ext/mysql/tests/mysql_field_type.phpt --TEST-- mysql_field_type() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysql_field_type())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (null !== ($tmp = @mysql_field_type($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysql_query("SELECT id, label FROM test ORDER BY id LIMIT 2", $link)) { printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link)); } if (NULL !== ($tmp = mysql_field_type($res))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysql_field_type($res, -1))) printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); var_dump(mysql_field_type($res, 0)); if (false !== ($tmp = mysql_field_type($res, 2))) printf("[008] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); mysql_free_result($res); var_dump(mysql_field_type($res, 0)); mysql_close($link); print "done!"; ?> --EXPECTF-- Warning: Wrong parameter count for mysql_field_type() in %s on line %d Warning: mysql_field_type(): Field -1 is invalid for MySQL result index %d in %s on line %d string(3) "int" Warning: mysql_field_type(): Field 2 is invalid for MySQL result index %d in %s on line %d Warning: mysql_field_type(): %d is not a valid MySQL result resource in %s on line %d bool(false) done! --UEXPECTF-- Warning: Wrong parameter count for mysql_field_type() in %s on line %d Warning: mysql_field_type(): Field -1 is invalid for MySQL result index %d in %s on line %d unicode(3) "int" Warning: mysql_field_type(): Field 2 is invalid for MySQL result index %d in %s on line %d Warning: mysql_field_type(): %d is not a valid MySQL result resource in %s on line %d bool(false) done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_free_result.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_free_result.phpt +++ php-src/ext/mysql/tests/mysql_free_result.phpt --TEST-- mysql_free_result() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysql_free_result())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = @mysql_free_result($link))) printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysql_query("SELECT id FROM test ORDER BY id LIMIT 1", $link)) { printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link)); } var_dump(mysql_free_result($res)); var_dump(mysql_free_result($res)); mysql_close($link); print "done!"; ?> --EXPECTF-- bool(true) Warning: mysql_free_result(): %d is not a valid MySQL result resource in %s on line %d bool(false) done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_get_client_info.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_get_client_info.phpt +++ php-src/ext/mysql/tests/mysql_get_client_info.phpt --TEST-- mysql_get_client_info() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; if (!is_string($info = mysql_get_client_info()) || ('' === $info)) printf("[001] Expecting string/any_non_empty, got %s/%s\n", gettype($info), $info); if (ini_get('unicode.semantics') && !is_unicode($info)) { printf("[002] Expecting Unicode!\n"); var_inspect($info); } print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_get_host_info.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_get_host_info.phpt +++ php-src/ext/mysql/tests/mysql_get_host_info.phpt --TEST-- mysql_get_host_info() --SKIPIF-- <?php require_once('skipif.inc'); ?> --FILE-- <?php include_once "connect.inc"; if (false !== ($tmp = @mysql_get_host_info(NULL))) printf("[001] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); require "table.inc"; if (!is_string($info = mysql_get_host_info($link)) || ('' === $info)) printf("[003] Expecting string/any_non_empty, got %s/%s\n", gettype($info), $info); $def_info = mysql_get_host_info(); if ($def_info !== $info) { printf("[004] Host info for the default link and the specified link differ, [%d] %s\n", mysql_errno(), mysql_error()); var_dump($def_info); var_dump($info); } if (ini_get('unicode.semantics') && !is_unicode($info)) { printf("[005] Expecting Unicode error message!\n"); var_inspect($info); } print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_get_proto_info.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_get_proto_info.phpt +++ php-src/ext/mysql/tests/mysql_get_proto_info.phpt --TEST-- mysql_get_proto_info() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include_once "connect.inc"; if (false !== ($tmp = @mysql_get_proto_info(NULL))) printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); require "table.inc"; if (!is_int($info = mysql_get_proto_info($link)) || (0 === $info)) printf("[003] Expecting int/any_non_empty, got %s/%s\n", gettype($info), $info); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_get_server_info.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_get_server_info.phpt +++ php-src/ext/mysql/tests/mysql_get_server_info.phpt --TEST-- mysql_get_server_info() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; if (false !== ($tmp = @mysql_get_server_info(NULL))) printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); require "table.inc"; if (!is_string($info = mysql_get_server_info($link)) || ('' === $info)) printf("[003] Expecting string/any_non_empty, got %s/%s\n", gettype($info), $info); $def_info = mysql_get_server_info(); if ($def_info !== $info) { printf("[004] Server info for the default link and the specified link differ, [%d] %s\n", mysql_errno(), mysql_error()); var_dump($def_info); var_dump($info); } if (ini_get('unicode.semantics') && !is_unicode($info)) { printf("[005] Expecting Unicode error message!\n"); var_inspect($info); } print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_info.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_info.phpt +++ php-src/ext/mysql/tests/mysql_info.phpt --TEST-- mysql_info() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; if (false !== ($tmp = @mysql_info())) printf("[001] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysql_info(NULL))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require "table.inc"; if (!$res = mysql_query('INSERT INTO test(id, label) VALUES (100, "a")', $link)) printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link)); if (false !== ($tmp = mysql_info($link))) printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (!$res = mysql_query('INSERT INTO test(id, label) VALUES (101, "a"), (102, "b")', $link)) printf("[005] [%d] %s\n", mysql_errno($link), mysql_error($link)); if (!is_string($tmp = mysql_info($link)) || ('' == $tmp)) printf("[006] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp); if (!$res = mysql_query('INSERT INTO test(id, label) SELECT id + 200, label FROM test', $link)) printf("[007] [%d] %s\n", mysql_errno($link), mysql_error($link)); if (!is_string($tmp = mysql_info($link)) || ('' == $tmp)) printf("[008] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp); if (!$res = mysql_query('ALTER TABLE test MODIFY label CHAR(2)', $link)) printf("[009] [%d] %s\n", mysql_errno($link), mysql_error($link)); if (!is_string($tmp = mysql_info($link)) || ('' == $tmp)) printf("[010] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp); if (!$res = mysql_query('UPDATE test SET label = "b" WHERE id >= 100', $link)) printf("[011] [%d] %s\n", mysql_errno($link), mysql_error($link)); if (!is_string($tmp = mysql_info($link)) || ('' == $tmp)) printf("[012] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp); if (ini_get('unicode.semantics') && !is_unicode($tmp)) { printf("[013] Expecting Unicode!\n"); var_inspect($info); } if (!is_string($def_tmp = mysql_info()) || ('' == $def_tmp)) printf("[014] Expecting string/any_non_empty, got %s/%s\n", gettype($def_tmp), $def_tmp); if ($def_tmp !== $tmp) { printf("[015] Results differ for default link and specified link, [%d] %s\n", mysql_errno(), mysql_error()); var_inspect($tmp); var_inspect($def_tmp); } // NOTE: no LOAD DATA INFILE test print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_insert_id.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_insert_id.phpt +++ php-src/ext/mysql/tests/mysql_insert_id.phpt --TEST-- mysql_insert_id() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (false !== ($tmp = @mysql_insert_id())) printf("[001] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = @mysql_insert_id($link))) printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (0 !== ($tmp = mysql_insert_id($link))) printf("[003] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); if (!$res = mysql_query("SELECT id, label FROM test ORDER BY id LIMIT 1", $link)) { printf("[004] [%d] %s\n", mysql_errno($link), mysql_error($link)); } if (0 !== ($tmp = mysql_insert_id($link))) printf("[005] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); mysql_free_result($res); // no auto_increment column if (!$res = mysql_query("INSERT INTO test(id, label) VALUES (100, 'a')", $link)) { printf("[006] [%d] %s\n", mysql_errno($link), mysql_error($link)); } if (0 !== ($tmp = mysql_insert_id($link))) printf("[007] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); if (!$res = mysql_query("ALTER TABLE test MODIFY id INT NOT NULL AUTO_INCREMENT", $link)) { printf("[008] [%d] %s\n", mysql_errno($link), mysql_error($link)); } if (!$res = mysql_query("INSERT INTO test(label) VALUES ('a')", $link)) { printf("[009] [%d] %s\n", mysql_errno($link), mysql_error($link)); } if (0 === ($tmp = mysql_insert_id($link))) printf("[010] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); mysql_close($link); var_dump(mysql_insert_id($link)); print "done!"; ?> --EXPECTF-- Warning: mysql_insert_id(): %d is not a valid MySQL-Link resource in %s on line %d bool(false) done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_list_dbs.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_list_dbs.phpt +++ php-src/ext/mysql/tests/mysql_list_dbs.phpt --TEST-- mysql_list_dbs() --SKIPIF-- <?php require_once('skipif.inc'); ?> --FILE-- <?php include_once "connect.inc"; $tmp = NULL; $link = NULL; if (false !== ($tmp = @mysql_list_dbs(NULL))) printf("[001] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysql_list_dbs($link, $link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysql_list_dbs($link)) printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link)); if (!$num = mysql_num_rows($res)) printf("[004] Empty database list? [%d] %s\n", mysql_errno($link), mysql_error($link)); $row = mysql_fetch_array($res, MYSQL_NUM); if (ini_get('unicode.semantics') && !is_unicode($row[0])) { printf("[005] Check for unicode support\n"); var_inspect($row); } mysql_free_result($res); mysql_close($link); print "done!\n"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_list_fields.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_list_fields.phpt +++ php-src/ext/mysql/tests/mysql_list_fields.phpt --TEST-- mysql_list_fields() --SKIPIF-- <?php require_once('skipif.inc'); ?> --FILE-- <?php include_once "connect.inc"; $tmp = NULL; $link = NULL; if (false !== ($tmp = @mysql_list_fields($link, $link))) printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysql_list_fields($db, 'test', $link)) printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link)); if (!($num = mysql_num_fields($res))) printf("[004] Empty field list? [%d] %s\n", mysql_errno($link), mysql_error($link)); mysql_free_result($res); mysql_close($link); print "done!\n"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_list_processes.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_list_processes.phpt +++ php-src/ext/mysql/tests/mysql_list_processes.phpt --TEST-- mysql_list_processes() --SKIPIF-- <?php require_once('skipif.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (NULL !== ($tmp = @mysql_list_processes($link, $link))) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysql_list_processes($link)) printf("[002] [%d] %s\n", mysql_errno($link), mysql_error($link)); if (!$num = mysql_num_rows($res)) printf("[003] Empty process list? [%d] %s\n", mysql_errno($link), mysql_error($link)); $row = mysql_fetch_array($res, MYSQL_NUM); if (ini_get('unicode.semantics') && !is_unicode($row[0])) { printf("[004] Check for unicode support\n"); var_inspect($row); } mysql_free_result($res); mysql_close($link); print "done!\n"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_num_fields.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_num_fields.phpt +++ php-src/ext/mysql/tests/mysql_num_fields.phpt --TEST-- mysql_num_fields() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysql_num_fields())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = @mysql_num_fields($link))) printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); function func_test_mysql_num_fields($link, $query, $expected, $offset, $test_free = false) { if (!($res = mysql_query($query, $link))) { printf("[%03d] [%d] %s\n", $offset, mysql_errno($link), mysql_error($link)); return; } if ($expected !== ($tmp = mysql_num_fields($res))) printf("[%03d] Expecting %s/%d, got %s/%d\n", $offset + 1, gettype($expected), $expected, gettype($tmp), $tmp); mysql_free_result($res); if ($test_free && (false !== ($tmp = mysql_num_fields($res)))) printf("[%03d] Expecting boolean/false, got %s/%s\n", $offset + 2, gettype($tmp), $tmp); } func_test_mysql_num_fields($link, "SELECT 1 AS a", 1, 5); func_test_mysql_num_fields($link, "SELECT id, label FROM test", 2, 10); func_test_mysql_num_fields($link, "SELECT 1 AS a, NULL AS b, 'foo' AS c", 3, 15); func_test_mysql_num_fields($link, "SELECT id FROM test", 1, 20, true); mysql_close($link); print "done!"; ?> --EXPECTF-- Warning: mysql_num_fields(): %d is not a valid MySQL result resource in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_num_rows.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_num_rows.phpt +++ php-src/ext/mysql/tests/mysql_num_rows.phpt --TEST-- mysql_num_rows() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysql_num_rows())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = @mysql_num_rows($link))) printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); function func_test_mysql_num_rows($link, $query, $expected, $offset, $test_free = false) { if (!$res = mysql_query($query, $link)) { printf("[%03d] [%d] %s\n", $offset, mysql_errno($link), mysql_error($link)); return; } if ($expected !== ($tmp = mysql_num_rows($res))) printf("[%03d] Expecting %s/%d, got %s/%d\n", $offset + 1, gettype($expected), $expected, gettype($tmp), $tmp); mysql_free_result($res); if ($test_free && (false !== ($tmp = mysql_num_rows($res)))) printf("[%03d] Expecting boolean/false, got %s/%s\n", $offset + 2, gettype($tmp), $tmp); } func_test_mysql_num_rows($link, "SELECT 1 AS a", 1, 5); func_test_mysql_num_rows($link, "SHOW VARIABLES LIKE '%nixnutz%'", 0, 10); func_test_mysql_num_rows($link, "INSERT INTO test(id, label) VALUES (100, 'z')", false, 15); func_test_mysql_num_rows($link, "SELECT id FROM test LIMIT 2", 2, 20, true); if ($res = mysql_query('SELECT COUNT(id) AS num FROM test', $link)) { $row = mysql_fetch_assoc($res); mysql_free_result($res); func_test_mysql_num_rows($link, "SELECT id, label FROM test", (int)$row['num'], 25); } else { printf("[030] [%d] %s\n", mysql_errno($link), mysql_error($link)); } mysql_close($link); print "done!"; ?> --EXPECTF-- Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in %s on line %d Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in %s on line %d Warning: mysql_num_rows(): %d is not a valid MySQL result resource in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_pconnect.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_pconnect.phpt +++ php-src/ext/mysql/tests/mysql_pconnect.phpt --TEST-- mysql_pconnect() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; // mysql_pconnect ( [string server [, string username [, string password [, bool new_link [, int client_flags]]]]] ) if (NULL !== ($tmp = @mysql_pconnect($link, $link, $link, $link, $link, $link))) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); $myhost = (is_null($socket)) ? ((is_null($port)) ? $host : $host . ':' . $port) : $host . ':' . $socket; if (!$link = mysql_pconnect($myhost, $user, $passwd, true)) printf("[002] Cannot connect to the server using host=%s/%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $myhost, $user, $db, $port, $socket); mysql_close($link); if ($link = mysql_pconnect($myhost, $user . 'unknown_really', $passwd . 'non_empty', true)) printf("[003] Can connect to the server using host=%s/%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", $host, $myhost, $user . 'unknown_really', $db, $port, $socket); if (false !== $link) printf("[004] Expecting boolean/false, got %s/%s\n", gettype($link), $link); // Run the following tests without an anoynmous MySQL user and use a password for the test user! ini_set('mysql.default_socket', $socket); if (!is_resource($link = mysql_pconnect($host, $user, $passwd, true))) { printf("[005] Usage of mysql.default_socket failed\n") ; } else { mysql_close($link); } if (!ini_get('sql.safe_mode')) { ini_set('mysql.default_port', $port); if (!is_resource($link = mysql_pconnect($host, $user, $passwd, true))) { printf("[006] Usage of mysql.default_port failed\n") ; } else { mysql_close($link); } ini_set('mysql.default_password', $passwd); if (!is_resource($link = mysql_pconnect($myhost, $user))) { printf("[007] Usage of mysql.default_password failed\n") ; } else { mysql_close($link); } ini_set('mysql.default_user', $user); if (!is_resource($link = mysql_pconnect($myhost))) { printf("[008] Usage of mysql.default_user failed\n"); } else { mysql_close($link); } ini_set('mysql.default_host', $myhost); if (!is_resource($link = mysql_pconnect())) { printf("[009] Usage of mysql.default_host failed\n") ; } else { mysql_close($link); } } print "done!"; ?> --EXPECTF-- Warning: mysql_pconnect(): Access denied for user '%s'@'%s' (using password: YES) in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_ping.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_ping.phpt +++ php-src/ext/mysql/tests/mysql_ping.phpt --TEST-- mysql_ping() --SKIPIF-- <?php require_once('skipif.inc'); ?> --FILE-- <?php include_once "connect.inc"; $tmp = NULL; $link = NULL; require('table.inc'); if (!is_null($tmp = @mysql_ping($link, $link))) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); var_dump(mysql_ping($link)); // provoke an error to check if mysql_ping resets it $res = mysql_query('SELECT * FROM unknown_table', $link); if (!($errno = mysql_errno($link))) printf("[002] Statement should have caused an error\n"); var_dump(mysql_ping($link)); if ($errno === mysql_errno($link)) printf("[003] Error codes should have been reset\n"); mysql_close($link); if (false !== ($tmp = mysql_ping($link))) printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- bool(true) bool(true) Warning: mysql_ping(): %d is not a valid MySQL-Link resource in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_query.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_query.phpt +++ php-src/ext/mysql/tests/mysql_query.phpt --TEST-- mysql_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 = @mysql_query())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = @mysql_query($link))) printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (NULL !== ($tmp = @mysql_query("SELECT 1 AS a", $link, "foo"))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysql_query('THIS IS NOT SQL', $link))) printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysql_query('SELECT "this is sql but with backslash g"\g', $link))) printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if ((0 === mysql_errno($link)) || ('' == mysql_error($link))) printf("[006] mysql_errno()/mysql_error should return some error\n"); if (!$res = mysql_query('SELECT "this is sql but with semicolon" AS valid ; ', $link)) printf("[007] [%d] %s\n", mysql_errno($link), mysql_error($link)); var_dump(mysql_fetch_assoc($res)); mysql_free_result($res); if (false !== ($res = mysql_query('SELECT "this is sql but with semicolon" AS valid ; SHOW VARIABLES', $link))) printf("[008] [%d] %s\n", mysql_errno($link), mysql_error($link)); if (mysql_query('DROP PROCEDURE IF EXISTS p', $link)) { // let's try to play with stored procedures if (mysql_query('CREATE PROCEDURE p(OUT ver_param VARCHAR(25)) BEGIN SELECT VERSION() INTO ver_param; END;', $link)) { $res = mysql_query('CALL p(@version)', $link); $res = mysql_query('SELECT @version AS p_version', $link); var_dump(mysql_fetch_assoc($res)); mysql_free_result($res); } else { printf("[009] [%d] %s\n", mysql_errno($link), mysql_error($link)); } mysql_query('DROP FUNCTION IF EXISTS f', $link); if (mysql_query('CREATE FUNCTION f( ver_param VARCHAR(25)) RETURNS VARCHAR(25) DETERMINISTIC RETURN ver_param;', $link)) { $res = mysql_query('SELECT f(VERSION()) AS f_version', $link); var_dump(mysql_fetch_assoc($res)); mysql_free_result($res); } else { printf("[010] [%d] %s\n", mysql_errno($link), mysql_error($link)); } } mysql_close($link); if (false !== ($tmp = mysql_query("SELECT id FROM test", $link))) printf("[011] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- array(1) { ["valid"]=> string(30) "this is sql but with semicolon" } array(1) { ["p_version"]=> string(%d) "%s" } array(1) { ["f_version"]=> string(%d) "%s" } Warning: mysql_query(): %d is not a valid MySQL-Link resource in %s on line %d done! --UEXPECTF-- array(1) { [u"valid"]=> unicode(30) "this is sql but with semicolon" } array(1) { [u"p_version"]=> unicode(%d) "%s" } array(1) { [u"f_version"]=> unicode(%d) "%s" } Warning: mysql_query(): %d is not a valid MySQL-Link resource in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_real_escape_string.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_real_escape_string.phpt +++ php-src/ext/mysql/tests/mysql_real_escape_string.phpt --TEST-- mysql_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 = @mysql_real_escape_string())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); var_dump(mysql_real_escape_string("Am I a unicode string in PHP 6?", $link)); var_dump(mysql_real_escape_string('\\', $link)); var_dump(mysql_real_escape_string('"', $link)); var_dump(mysql_real_escape_string("'", $link)); var_dump(mysql_real_escape_string("\n", $link)); var_dump(mysql_real_escape_string("\r", $link)); var_dump(mysql_real_escape_string("foo" . chr(0) . "bar", $link)); print "done!"; ?> --EXPECTF-- string(31) "Am I a unicode string in PHP 6?" string(2) "\\" string(2) "\"" string(2) "\'" string(2) "\n" string(2) "\r" string(8) "foo\0bar" done! --UEXPECTF-- unicode(31) "Am I a unicode string in PHP 6?" unicode(2) "\\" unicode(2) "\"" unicode(2) "\'" unicode(2) "\n" unicode(2) "\r" unicode(8) "foo\0bar" done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_result.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_result.phpt +++ php-src/ext/mysql/tests/mysql_result.phpt --TEST-- mysql_result() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; // string mysql_result ( resource result, int row [, mixed field] ) if (!is_null($tmp = @mysql_result())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysql_result($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysql_query("SELECT id, label FROM test ORDER BY id LIMIT 1", $link)) { printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link)); } var_dump(mysql_result($res, -1)); var_dump(mysql_result($res, 2)); var_dump(mysql_result($res, 0, -1)); var_dump(mysql_result($res, 0, 2)); var_dump(mysql_result($res, 0)); var_dump(mysql_result($res, 0, 1)); mysql_free_result($res); var_dump(mysql_result($res, 0)); mysql_close($link); print "done!"; ?> --EXPECTF-- Warning: mysql_result(): Unable to jump to row -1 on MySQL result index %d in %s on line %d bool(false) Warning: mysql_result(): Unable to jump to row 2 on MySQL result index %d in %s on line %d bool(false) Warning: mysql_result(): Bad column offset specified in %s on line %d bool(false) Warning: mysql_result(): Bad column offset specified in %s on line %d bool(false) string(1) "1" string(1) "a" Warning: mysql_result(): %d is not a valid MySQL result resource in %s on line %d bool(false) done! --UEXPECTF-- Warning: mysql_result(): Unable to jump to row -1 on MySQL result index %d in %s on line %d bool(false) Warning: mysql_result(): Unable to jump to row 2 on MySQL result index %d in %s on line %d bool(false) Warning: mysql_result(): Bad column offset specified in %s on line %d bool(false) Warning: mysql_result(): Bad column offset specified in %s on line %d bool(false) unicode(1) "1" unicode(1) "a" Warning: mysql_result(): %d is not a valid MySQL result resource in %s on line %d bool(false) done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_select_db.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_select_db.phpt +++ php-src/ext/mysql/tests/mysql_select_db.phpt --TEST-- mysql_select_db() --SKIPIF-- <?php require_once('skipif.inc'); ?> --FILE-- <?php include_once "connect.inc"; $tmp = NULL; $link = NULL; if (false !== ($tmp = @mysql_select_db($link))) printf("[001] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (!is_null($tmp = @mysql_select_db($db, $link, "foo"))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); /* does not make too much sense, unless we have access to at least one more database than $db */ if (!mysql_select_db($db, $link)) printf("[004] Cannot select DB %s, [%d] %s\n", $db, mysql_errno($link), mysql_error($link)); if (!$res = mysql_query("SELECT DATABASE() AS dbname", $link)) printf("[005] [%d] %s\n", mysql_errno($link), mysql_error($link)); if (!$row = mysql_fetch_assoc($res)) printf("[006] [%d] %s\n", mysql_errno($link), mysql_error($link)); if ($row['dbname'] !== (string)$db) printf("[007] Expecting database '%s', found '%s'\n", $db, $row['dbname']); var_dump($row['dbname']); mysql_free_result($res); if (mysql_select_db('mysql', $link)) { // Yippie, a second database to play with - that's great because mysql_select_db // ($db) was done by mysql__connect() already and the previous test // was quite useless if (!$res = mysql_query("SELECT DATABASE() AS dbname", $link)) printf("[008] [%d] %s\n", mysql_errno($link), mysql_error($link)); if (!$row = mysql_fetch_assoc($res)) printf("[009] [%d] %s\n", mysql_errno($link), mysql_error($link)); if (strtolower($row['dbname']) !== 'mysql') printf("[010] Expecting database 'mysql', found '%s'\n", $row['dbname']); mysql_free_result($res); } var_dump(mysql_select_db('I can not imagine that this database exists', $link)); mysql_close($link); if (false !== ($tmp = mysql_select_db($db, $link))) printf("[012] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); print "done!\n"; ?> --EXPECTF-- string(7) "phptest" bool(false) Warning: mysql_select_db(): %d is not a valid MySQL-Link resource in %s on line %d done! --UEXPECTF-- unicode(7) "phptest" bool(false) Warning: mysql_select_db(): %d is not a valid MySQL-Link resource in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_stat.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_stat.phpt +++ php-src/ext/mysql/tests/mysql_stat.phpt --TEST-- mysql_stat() --SKIPIF-- <?php require_once('skipif.inc'); ?> --FILE-- <?php include_once "connect.inc"; $dbname = 'test'; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysql_stat($link))) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!is_null($tmp = @mysql_stat($link, "foo"))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if ((!is_string($tmp = mysql_stat($link))) || ('' === $tmp)) printf("[003] Expecting non empty string, got %s/'%s', [%d] %s\n", gettype($tmp), $tmp, mysql_errno($link), mysql_error($link)); if (ini_get('unicode.semantics') && !is_unicode($tmp)) { printf("[004] Expecting Unicode error message!\n"); var_inspect($tmp); } mysql_close($link); if (false !== ($tmp = mysql_stat($link))) printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysql_stat(): %d is not a valid MySQL-Link resource in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_tablename.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_tablename.phpt +++ php-src/ext/mysql/tests/mysql_tablename.phpt --TEST-- mysql_tablename() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysql_tablename())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (null !== ($tmp = @mysql_tablename($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysql_query("SELECT id, label FROM test ORDER BY id LIMIT 2", $link)) { printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link)); } if (NULL !== ($tmp = mysql_tablename($res))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysql_tablename($res, -1))) printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); var_dump(mysql_tablename($res, 0)); if (false !== ($tmp = mysql_tablename($res, 2))) printf("[00%d] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); mysql_free_result($res); var_dump(mysql_tablename($res, 0)); mysql_close($link); print "done!"; ?> --EXPECTF-- Warning: Wrong parameter count for mysql_tablename() in %s on line %d Warning: mysql_tablename(): Unable to jump to row -1 on MySQL result index %d in %s on line %d string(1) "1" Warning: mysql_tablename(): Unable to jump to row 2 on MySQL result index %d in %s on line %d Warning: mysql_tablename(): %d is not a valid MySQL result resource in %s on line %d bool(false) done! --UEXPECTF-- Warning: Wrong parameter count for mysql_tablename() in %s on line %d Warning: mysql_tablename(): Unable to jump to row -1 on MySQL result index %d in %s on line %d unicode(1) "1" Warning: mysql_tablename(): Unable to jump to row 2 on MySQL result index %d in %s on line %d Warning: mysql_tablename(): %d is not a valid MySQL result resource in %s on line %d bool(false) done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_thread_id.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_thread_id.phpt +++ php-src/ext/mysql/tests/mysql_thread_id.phpt --TEST-- mysql_thread_id() --SKIPIF-- <?php require_once('skipif.inc'); ?> --FILE-- <?php include_once "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysql_thread_id($link))) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!is_int($tmp = mysql_thread_id($link)) || (0 === $tmp)) printf("[002] Expecting int/any but zero, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysql_errno($link), mysql_error($link)); mysql_close($link); if (false !== ($tmp = mysql_thread_id($link))) printf("[003] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysql_thread_id(): %d is not a valid MySQL-Link resource in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_unbuffered_query.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_unbuffered_query.phpt +++ php-src/ext/mysql/tests/mysql_unbuffered_query.phpt --TEST-- mysql_unbuffered_query() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (false !== ($tmp = @mysql_unbuffered_query($link))) printf("[001] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (NULL !== ($tmp = @mysql_unbuffered_query("SELECT 1 AS a", $link, "foo"))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysql_unbuffered_query('THIS IS NOT SQL', $link))) printf("[003] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysql_unbuffered_query('SELECT "this is sql but with backslash g"\g', $link))) printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if ((0 === mysql_errno($link)) || ('' == mysql_error($link))) printf("[005] mysql_errno()/mysql_error should return some error\n"); if (!$res = mysql_unbuffered_query('SELECT "this is sql but with semicolon" AS valid ; ', $link)) printf("[006] [%d] %s\n", mysql_errno($link), mysql_error($link)); var_dump(mysql_fetch_assoc($res)); mysql_free_result($res); if (false !== ($res = mysql_unbuffered_query('SELECT "this is sql but with semicolon" AS valid ; SHOW VARIABLES', $link))) printf("[007] [%d] %s\n", mysql_errno($link), mysql_error($link)); if (mysql_unbuffered_query('DROP PROCEDURE IF EXISTS p', $link)) { // let's try to play with stored procedures if (mysql_unbuffered_query('CREATE PROCEDURE p(OUT ver_param VARCHAR(25)) BEGIN SELECT VERSION() INTO ver_param; END;', $link)) { $res = mysql_unbuffered_query('CALL p(@version)', $link); $res = mysql_unbuffered_query('SELECT @version AS p_version', $link); var_dump(mysql_fetch_assoc($res)); mysql_free_result($res); } else { printf("[008] [%d] %s\n", mysql_errno($link), mysql_error($link)); } mysql_unbuffered_query('DROP FUNCTION IF EXISTS f', $link); if (mysql_unbuffered_query('CREATE FUNCTION f( ver_param VARCHAR(25)) RETURNS VARCHAR(25) DETERMINISTIC RETURN ver_param;', $link)) { $res = mysql_unbuffered_query('SELECT f(VERSION()) AS f_version', $link); var_dump(mysql_fetch_assoc($res)); mysql_free_result($res); } else { printf("[009] [%d] %s\n", mysql_errno($link), mysql_error($link)); } } var_dump(mysql_unbuffered_query('INSERT INTO test(id) VALUES (100)', $link)); var_dump($res = mysql_unbuffered_query('SELECT id FROM test', $link)); var_dump(mysql_num_rows($res)); mysql_close($link); if (false !== ($tmp = mysql_unbuffered_query("SELECT id FROM test", $link))) printf("[010] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- array(1) { ["valid"]=> string(30) "this is sql but with semicolon" } array(1) { ["p_version"]=> string(16) "5.0.26-debug-log" } array(1) { ["f_version"]=> string(16) "5.0.26-debug-log" } bool(true) resource(%d) of type (mysql result) int(0) Notice: mysql_close(): Function called without first fetching all rows from a previous unbuffered query in %s on line %d Warning: mysql_unbuffered_query(): %d is not a valid MySQL-Link resource in %s on line %d done! --UEXPECTF-- array(1) { [u"valid"]=> unicode(30) "this is sql but with semicolon" } array(1) { [u"p_version"]=> unicode(16) "5.0.26-debug-log" } array(1) { [u"f_version"]=> unicode(16) "5.0.26-debug-log" } bool(true) resource(%d) of type (mysql result) int(0) Notice: mysql_close(): Function called without first fetching all rows from a previous unbuffered query in %s on line %d Warning: mysql_unbuffered_query(): %d is not a valid MySQL-Link resource in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/table.inc?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/table.inc +++ php-src/ext/mysql/tests/table.inc <?PHP require_once('connect.inc'); // connect + select_db if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) { printf("Cannot connect to the server using host=%s/%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $myhost, $user, $db, $port, $socket); exit(1); } if (!mysql_query('DROP TABLE IF EXISTS test', $link)) { printf("Failed to drop old test table: [%d] %s\n", mysql_errno($link), mysql_error($link)); exit(1); } if (!mysql_query('CREATE TABLE test(id INT, label CHAR(1), PRIMARY KEY(id)) ENGINE=' . $engine, $link)) { printf("Failed to create test table: [%d] %s\n", mysql_errno($link), mysql_error($link)); exit(1); } if (!mysql_query('INSERT INTO test(id, label) VALUES (1, "a"), (2, "b"), (3, "c"), (4, "d"), (5, "e"), (6, "f")', $link)) { printf("[%d] %s\n", mysql_errno($link), mysql_error($link)); } ?>
« previous php.cvs (#41633) next »