cvs: php-src(PHP_5_3) /ext/mysql/tests mysql_affected_rows.phpt mysql_client_encoding.phpt mysql_close.phpt mysql_connect.phpt mysql_constants.phpt
mysql_create_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
| From: | Ulf Wendel | Date: | Wed, 10 Oct 2007 09:51:46 +0000 |
| Subject: | cvs: php-src(PHP_5_3) /ext/mysql/tests mysql_affected_rows.phpt mysql_client_encoding.phpt mysql_close.phpt mysql_connect.phpt mysql_constants.phpt mysql_create_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 |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-46588@lists.php.net to get a copy of this message | ||
uw Wed Oct 10 09:51:46 2007 UTC
Added files: (Branch: PHP_5_3)
/php-src/ext/mysql/tests mysql_affected_rows.phpt
mysql_client_encoding.phpt
mysql_close.phpt mysql_connect.phpt
mysql_constants.phpt mysql_create_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
Log:
Adding new tests.
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_constants.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_constants.phpt +++ php-src/ext/mysql/tests/mysql_constants.phpt --TEST-- Constants exported by ext/mysql --SKIPIF-- <?php require_once('skipif.inc'); ?> --FILE-- <?php require("connect.inc"); require("table.inc"); $constants = get_defined_constants(true); sort($constants); $expected_constants = array( 'MYSQL_ASSOC' => true, 'MYSQL_NUM' => true, 'MYSQL_BOTH' => true, 'MYSQL_CLIENT_COMPRESS' => true, 'MYSQL_CLIENT_INTERACTIVE' => true, 'MYSQL_CLIENT_IGNORE_SPACE' => true, ); $version = mysql_get_server_info($link); if (!preg_match('@(\d+)\.(\d+)\.(\d+)@ism', $version, $matches)) printf("[001] Cannot get server version\n"); $version = ($matches[1] * 100) + ($matches[2] * 10) + $matches[3]; if ($version > 400) { $expected_constants = array_merge($expected_constants, array( "MYSQL_CLIENT_SSL" => true, )); } $unexpected_constants = array(); foreach ($constants as $group => $consts) { foreach ($consts as $name => $value) { if (stristr($name, 'mysql') && !stristr($name, 'mysqli')) { $name = strtoupper($name); if (isset($expected_constants[$name])) { unset($expected_constants[$name]); } else { $unexpected_constants[$name] = $name; } } } } if (!empty($unexpected_constants)) { printf("Dumping list of unexpected constants\n"); var_dump($unexpected_constants); } if (!empty($expected_constants)) { printf("Dumping list of missing constants\n"); var_dump($expected_constants); } print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/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_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_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_constants.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_constants.phpt +++ php-src/ext/mysql/tests/mysql_constants.phpt --TEST-- Constants exported by ext/mysql --SKIPIF-- <?php require_once('skipif.inc'); ?> --FILE-- <?php require("connect.inc"); require("table.inc"); $constants = get_defined_constants(true); sort($constants); $expected_constants = array( 'MYSQL_ASSOC' => true, 'MYSQL_NUM' => true, 'MYSQL_BOTH' => true, 'MYSQL_CLIENT_COMPRESS' => true, 'MYSQL_CLIENT_INTERACTIVE' => true, 'MYSQL_CLIENT_IGNORE_SPACE' => true, ); $version = mysql_get_server_info($link); if (!preg_match('@(\d+)\.(\d+)\.(\d+)@ism', $version, $matches)) printf("[001] Cannot get server version\n"); $version = ($matches[1] * 100) + ($matches[2] * 10) + $matches[3]; if ($version > 400) { $expected_constants = array_merge($expected_constants, array( "MYSQL_CLIENT_SSL" => true, )); } $unexpected_constants = array(); foreach ($constants as $group => $consts) { foreach ($consts as $name => $value) { if (stristr($name, 'mysql') && !stristr($name, 'mysqli')) { $name = strtoupper($name); if (isset($expected_constants[$name])) { unset($expected_constants[$name]); } else { $unexpected_constants[$name] = $name; } } } } if (!empty($unexpected_constants)) { printf("Dumping list of unexpected constants\n"); var_dump($unexpected_constants); } if (!empty($expected_constants)) { printf("Dumping list of missing constants\n"); var_dump($expected_constants); } print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/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_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!