From 69a3575b380750380edb764c86e96af9e7ed849c Mon Sep 17 00:00:00 2001 From: Kalle Sommer Nielsen Date: Fri, 7 Jan 2011 18:25:55 +0000 Subject: [PATCH] Implemented FR #39847 (mysqli_fetch_[field|fields|field_direct] need to return db) --- NEWS | 8 +++---- UPGRADING | 2 ++ ext/mysqli/mysqli_api.c | 1 + ext/mysqli/tests/047.phpt | 24 ++++++++++++++----- ext/mysqli/tests/mysqli_fetch_field.phpt | 12 +++++++--- .../tests/mysqli_fetch_field_direct.phpt | 4 +++- .../tests/mysqli_fetch_field_direct_oo.phpt | 4 +++- ext/mysqli/tests/mysqli_fetch_field_oo.phpt | 8 +++++-- ext/mysqli/tests/mysqli_fetch_fields.phpt | 8 +++++-- ext/mysqli/tests/mysqli_field_seek.phpt | 16 +++++++++---- ext/mysqli/tests/mysqli_field_tell.phpt | 4 +++- ..._stmt_get_result_metadata_fetch_field.phpt | 16 +++++++++---- .../tests/mysqli_stmt_result_metadata.phpt | 4 +++- 13 files changed, 82 insertions(+), 29 deletions(-) diff --git a/NEWS b/NEWS index a21a7c27b2..c6a8d66606 100644 --- a/NEWS +++ b/NEWS @@ -158,6 +158,10 @@ PHP NEWS . mysqlnd: Added named pipes support. FR #48082. (Andrey) . MySQLi: Added iterator support in MySQLi. mysqli_result implements Traversable. (Andrey, Johannes) + . MySQLi: Implemented FR #39847 (mysqli_fetch_[field|fields|field_direct] + need to return db). (Kalle) + . PDO_mysql: Implemented FR #47802 (Support for setting character sets in + DSN strings). (Kalle) . PDO_mysql: Removed support for linking with MySQL client libraries older than 4.1. (Johannes) @@ -170,10 +174,6 @@ PHP NEWS . Added nextRowset support. . Fixed bug #50755 (PDO DBLIB Fails with OOM). -- Improved PDO MySQL: - . Implemented FR #47802 (Support for setting character sets in DSN strings). - (Kalle) - - Improved Reflection extension: (Johannes) . Added ReflectionExtension::isTemporary() and ReflectionExtension::isPersistent() methods. diff --git a/UPGRADING b/UPGRADING index 25a67979cc..0d7d1c2811 100755 --- a/UPGRADING +++ b/UPGRADING @@ -163,6 +163,8 @@ UPGRADE NOTES - PHP X.Y present in the result. - pdo_mysql now supports setting character sets when connecting in the DSN string. +- mysqli_fetch_[field|fields|field_direct] now returns an additional property + named 'db' that contains the database name of the associated result. =================================== diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c index 487474efc9..c75c9f8ec2 100644 --- a/ext/mysqli/mysqli_api.c +++ b/ext/mysqli/mysqli_api.c @@ -1052,6 +1052,7 @@ static void php_add_field_properties(zval *value, const MYSQL_FIELD *field TSRML add_property_string(value, "table",(field->table ? field->table : ""), 1); add_property_string(value, "orgtable",(field->org_table ? field->org_table : ""), 1); add_property_string(value, "def",(field->def ? field->def : ""), 1); + add_property_string(value, "db",(field->db ? field->db : ""), 1); add_property_long(value, "max_length", field->max_length); add_property_long(value, "length", field->length); diff --git a/ext/mysqli/tests/047.phpt b/ext/mysqli/tests/047.phpt index 65c951c080..e6dce51863 100644 --- a/ext/mysqli/tests/047.phpt +++ b/ext/mysqli/tests/047.phpt @@ -60,7 +60,7 @@ mysqli_close($link); === fetch_fields === array(2) { [0]=> - object(stdClass)#5 (11) { + object(stdClass)#5 (12) { [%u|b%"name"]=> %unicode|string%(3) "foo" [%u|b%"orgname"]=> @@ -71,6 +71,8 @@ array(2) { %unicode|string%(13) "test_affected" [%u|b%"def"]=> %unicode|string%(0) "" + [%u|b%"db"]=> + %unicode|string%(4) "test" [%u|b%"max_length"]=> int(0) [%u|b%"length"]=> @@ -85,7 +87,7 @@ array(2) { int(0) } [1]=> - object(stdClass)#6 (11) { + object(stdClass)#6 (12) { [%u|b%"name"]=> %unicode|string%(3) "bar" [%u|b%"orgname"]=> @@ -96,6 +98,8 @@ array(2) { %unicode|string%(13) "test_affected" [%u|b%"def"]=> %unicode|string%(0) "" + [%u|b%"db"]=> + %unicode|string%(4) "test" [%u|b%"max_length"]=> int(0) [%u|b%"length"]=> @@ -112,7 +116,7 @@ array(2) { } === fetch_field_direct === -object(stdClass)#6 (11) { +object(stdClass)#6 (12) { [%u|b%"name"]=> %unicode|string%(3) "foo" [%u|b%"orgname"]=> @@ -123,6 +127,8 @@ object(stdClass)#6 (11) { %unicode|string%(13) "test_affected" [%u|b%"def"]=> %unicode|string%(0) "" + [%u|b%"db"]=> + %unicode|string%(4) "test" [%u|b%"max_length"]=> int(0) [%u|b%"length"]=> @@ -136,7 +142,7 @@ object(stdClass)#6 (11) { [%u|b%"decimals"]=> int(0) } -object(stdClass)#6 (11) { +object(stdClass)#6 (12) { [%u|b%"name"]=> %unicode|string%(3) "bar" [%u|b%"orgname"]=> @@ -147,6 +153,8 @@ object(stdClass)#6 (11) { %unicode|string%(13) "test_affected" [%u|b%"def"]=> %unicode|string%(0) "" + [%u|b%"db"]=> + %unicode|string%(4) "test" [%u|b%"max_length"]=> int(0) [%u|b%"length"]=> @@ -162,7 +170,7 @@ object(stdClass)#6 (11) { } === fetch_field === -object(stdClass)#6 (11) { +object(stdClass)#6 (12) { [%u|b%"name"]=> %unicode|string%(3) "foo" [%u|b%"orgname"]=> @@ -173,6 +181,8 @@ object(stdClass)#6 (11) { %unicode|string%(13) "test_affected" [%u|b%"def"]=> %unicode|string%(0) "" + [%u|b%"db"]=> + %unicode|string%(4) "test" [%u|b%"max_length"]=> int(0) [%u|b%"length"]=> @@ -186,7 +196,7 @@ object(stdClass)#6 (11) { [%u|b%"decimals"]=> int(0) } -object(stdClass)#5 (11) { +object(stdClass)#5 (12) { [%u|b%"name"]=> %unicode|string%(3) "bar" [%u|b%"orgname"]=> @@ -197,6 +207,8 @@ object(stdClass)#5 (11) { %unicode|string%(13) "test_affected" [%u|b%"def"]=> %unicode|string%(0) "" + [%u|b%"db"]=> + %unicode|string%(4) "test" [%u|b%"max_length"]=> int(0) [%u|b%"length"]=> diff --git a/ext/mysqli/tests/mysqli_fetch_field.phpt b/ext/mysqli/tests/mysqli_fetch_field.phpt index 4dde6c9aaf..571a28b7a5 100644 --- a/ext/mysqli/tests/mysqli_fetch_field.phpt +++ b/ext/mysqli/tests/mysqli_fetch_field.phpt @@ -79,7 +79,7 @@ require_once('skipifconnectfailure.inc'); require_once("clean_table.inc"); ?> --EXPECTF-- -object(stdClass)#%d (11) { +object(stdClass)#%d (12) { [%u|b%"name"]=> %unicode|string%(2) "ID" [%u|b%"orgname"]=> @@ -90,6 +90,8 @@ object(stdClass)#%d (11) { %unicode|string%(4) "test" [%u|b%"def"]=> %unicode|string%(0) "" + [%u|b%"db"]=> + %unicode|string%(4) "test" [%u|b%"max_length"]=> int(1) [%u|b%"length"]=> @@ -103,7 +105,7 @@ object(stdClass)#%d (11) { [%u|b%"decimals"]=> int(0) } -object(stdClass)#%d (11) { +object(stdClass)#%d (12) { [%u|b%"name"]=> %unicode|string%(5) "label" [%u|b%"orgname"]=> @@ -114,6 +116,8 @@ object(stdClass)#%d (11) { %unicode|string%(4) "test" [%u|b%"def"]=> %unicode|string%(0) "" + [%u|b%"db"]=> + %unicode|string%(4) "test" [%u|b%"max_length"]=> int(%d) [%u|b%"length"]=> @@ -134,7 +138,7 @@ array(1) { [%u|b%"_default_test"]=> %unicode|string%(1) "2" } -object(stdClass)#%d (11) { +object(stdClass)#%d (12) { [%u|b%"name"]=> %unicode|string%(13) "_default_test" [%u|b%"orgname"]=> @@ -145,6 +149,8 @@ object(stdClass)#%d (11) { %unicode|string%(4) "test" [%u|b%"def"]=> %unicode|string%(0) "" + [%u|b%"db"]=> + %unicode|string%(4) "test" [%u|b%"max_length"]=> int(1) [%u|b%"length"]=> diff --git a/ext/mysqli/tests/mysqli_fetch_field_direct.phpt b/ext/mysqli/tests/mysqli_fetch_field_direct.phpt index 33c5a0cf30..7eaa4b672e 100644 --- a/ext/mysqli/tests/mysqli_fetch_field_direct.phpt +++ b/ext/mysqli/tests/mysqli_fetch_field_direct.phpt @@ -47,7 +47,7 @@ require_once('skipifconnectfailure.inc'); --EXPECTF-- Warning: mysqli_fetch_field_direct(): Field offset is invalid for resultset in %s on line %d bool(false) -object(stdClass)#%d (11) { +object(stdClass)#%d (12) { [%u|b%"name"]=> %unicode|string%(2) "ID" [%u|b%"orgname"]=> @@ -58,6 +58,8 @@ object(stdClass)#%d (11) { %unicode|string%(4) "test" [%u|b%"def"]=> %unicode|string%(0) "" + [%u|b%"db"]=> + %unicode|string%(4) "test" [%u|b%"max_length"]=> int(%d) [%u|b%"length"]=> diff --git a/ext/mysqli/tests/mysqli_fetch_field_direct_oo.phpt b/ext/mysqli/tests/mysqli_fetch_field_direct_oo.phpt index 23d46f3092..082ecbcc27 100644 --- a/ext/mysqli/tests/mysqli_fetch_field_direct_oo.phpt +++ b/ext/mysqli/tests/mysqli_fetch_field_direct_oo.phpt @@ -56,7 +56,7 @@ require_once('skipifconnectfailure.inc'); --EXPECTF-- Warning: mysqli_result::fetch_field_direct(): Field offset is invalid for resultset in %s on line %d bool(false) -object(stdClass)#%d (11) { +object(stdClass)#%d (12) { [%u|b%"name"]=> %unicode|string%(2) "ID" [%u|b%"orgname"]=> @@ -67,6 +67,8 @@ object(stdClass)#%d (11) { %unicode|string%(4) "test" [%u|b%"def"]=> %unicode|string%(0) "" + [%u|b%"db"]=> + %unicode|string%(4) "test" [%u|b%"max_length"]=> int(%d) [%u|b%"length"]=> diff --git a/ext/mysqli/tests/mysqli_fetch_field_oo.phpt b/ext/mysqli/tests/mysqli_fetch_field_oo.phpt index 0130f0e7f2..2b347e279e 100644 --- a/ext/mysqli/tests/mysqli_fetch_field_oo.phpt +++ b/ext/mysqli/tests/mysqli_fetch_field_oo.phpt @@ -63,7 +63,7 @@ require_once('skipifconnectfailure.inc'); require_once("clean_table.inc"); ?> --EXPECTF-- -object(stdClass)#%d (11) { +object(stdClass)#%d (12) { [%u|b%"name"]=> %unicode|string%(2) "ID" [%u|b%"orgname"]=> @@ -74,6 +74,8 @@ object(stdClass)#%d (11) { %unicode|string%(4) "test" [%u|b%"def"]=> %unicode|string%(0) "" + [%u|b%"db"]=> + %unicode|string%(4) "test" [%u|b%"max_length"]=> int(1) [%u|b%"length"]=> @@ -87,7 +89,7 @@ object(stdClass)#%d (11) { [%u|b%"decimals"]=> int(0) } -object(stdClass)#%d (11) { +object(stdClass)#%d (12) { [%u|b%"name"]=> %unicode|string%(5) "label" [%u|b%"orgname"]=> @@ -98,6 +100,8 @@ object(stdClass)#%d (11) { %unicode|string%(4) "test" [%u|b%"def"]=> %unicode|string%(0) "" + [%u|b%"db"]=> + %unicode|string%(4) "test" [%u|b%"max_length"]=> int(%d) [%u|b%"length"]=> diff --git a/ext/mysqli/tests/mysqli_fetch_fields.phpt b/ext/mysqli/tests/mysqli_fetch_fields.phpt index 885c7338b5..1d27936d16 100644 --- a/ext/mysqli/tests/mysqli_fetch_fields.phpt +++ b/ext/mysqli/tests/mysqli_fetch_fields.phpt @@ -60,7 +60,7 @@ require_once('skipifconnectfailure.inc'); require_once("clean_table.inc"); ?> --EXPECTF-- -object(stdClass)#%d (11) { +object(stdClass)#%d (12) { [%u|b%"name"]=> %unicode|string%(2) "ID" [%u|b%"orgname"]=> @@ -71,6 +71,8 @@ object(stdClass)#%d (11) { %unicode|string%(4) "test" [%u|b%"def"]=> %unicode|string%(0) "" + [%u|b%"db"]=> + %unicode|string%(4) "test" [%u|b%"max_length"]=> int(1) [%u|b%"length"]=> @@ -84,7 +86,7 @@ object(stdClass)#%d (11) { [%u|b%"decimals"]=> int(0) } -object(stdClass)#%d (11) { +object(stdClass)#%d (12) { [%u|b%"name"]=> %unicode|string%(5) "label" [%u|b%"orgname"]=> @@ -95,6 +97,8 @@ object(stdClass)#%d (11) { %unicode|string%(4) "test" [%u|b%"def"]=> %unicode|string%(0) "" + [%u|b%"db"]=> + %unicode|string%(4) "test" [%u|b%"max_length"]=> int(1) [%u|b%"length"]=> diff --git a/ext/mysqli/tests/mysqli_field_seek.phpt b/ext/mysqli/tests/mysqli_field_seek.phpt index 1da42c2833..00b463de9b 100644 --- a/ext/mysqli/tests/mysqli_field_seek.phpt +++ b/ext/mysqli/tests/mysqli_field_seek.phpt @@ -122,7 +122,7 @@ require_once('skipifconnectfailure.inc'); --EXPECTF-- Warning: mysqli_field_seek(): Invalid field offset in %s on line %d bool(false) -object(stdClass)#%d (11) { +object(stdClass)#%d (12) { [%u|b%"name"]=> %unicode|string%(2) "id" [%u|b%"orgname"]=> @@ -133,6 +133,8 @@ object(stdClass)#%d (11) { %unicode|string%(4) "test" [%u|b%"def"]=> %unicode|string%(0) "" + [%u|b%"db"]=> + %unicode|string%(4) "test" [%u|b%"max_length"]=> int(0) [%u|b%"length"]=> @@ -147,7 +149,7 @@ object(stdClass)#%d (11) { int(0) } bool(true) -object(stdClass)#%d (11) { +object(stdClass)#%d (12) { [%u|b%"name"]=> %unicode|string%(2) "id" [%u|b%"orgname"]=> @@ -158,6 +160,8 @@ object(stdClass)#%d (11) { %unicode|string%(4) "test" [%u|b%"def"]=> %unicode|string%(0) "" + [%u|b%"db"]=> + %unicode|string%(4) "test" [%u|b%"max_length"]=> int(0) [%u|b%"length"]=> @@ -172,7 +176,7 @@ object(stdClass)#%d (11) { int(0) } bool(true) -object(stdClass)#%d (11) { +object(stdClass)#%d (12) { [%u|b%"name"]=> %unicode|string%(5) "label" [%u|b%"orgname"]=> @@ -183,6 +187,8 @@ object(stdClass)#%d (11) { %unicode|string%(4) "test" [%u|b%"def"]=> %unicode|string%(0) "" + [%u|b%"db"]=> + %unicode|string%(4) "test" [%u|b%"max_length"]=> int(%d) [%u|b%"length"]=> @@ -205,7 +211,7 @@ bool(false) Warning: mysqli_field_seek(): Invalid field offset in %s on line %d bool(false) bool(true) -object(stdClass)#3 (11) { +object(stdClass)#3 (12) { [%u|b%"name"]=> %unicode|string%(5) "_null" [%u|b%"orgname"]=> @@ -216,6 +222,8 @@ object(stdClass)#3 (11) { %unicode|string%(0) "" [%u|b%"def"]=> %unicode|string%(0) "" + [%u|b%"db"]=> + %unicode|string%(0) "" [%u|b%"max_length"]=> int(0) [%u|b%"length"]=> diff --git a/ext/mysqli/tests/mysqli_field_tell.phpt b/ext/mysqli/tests/mysqli_field_tell.phpt index f1e43c4912..aeeac3510e 100644 --- a/ext/mysqli/tests/mysqli_field_tell.phpt +++ b/ext/mysqli/tests/mysqli_field_tell.phpt @@ -64,7 +64,7 @@ int(0) Warning: mysqli_field_seek() expects exactly 2 parameters, 1 given in %s on line %d NULL int(0) -object(stdClass)#%d (11) { +object(stdClass)#%d (12) { [%u|b%"name"]=> %unicode|string%(2) "id" [%u|b%"orgname"]=> @@ -75,6 +75,8 @@ object(stdClass)#%d (11) { %unicode|string%(4) "test" [%u|b%"def"]=> %unicode|string%(0) "" + [%u|b%"db"]=> + %unicode|string%(4) "test" [%u|b%"max_length"]=> int(0) [%u|b%"length"]=> diff --git a/ext/mysqli/tests/mysqli_stmt_get_result_metadata_fetch_field.phpt b/ext/mysqli/tests/mysqli_stmt_get_result_metadata_fetch_field.phpt index 23d045a22b..c225cf4214 100644 --- a/ext/mysqli/tests/mysqli_stmt_get_result_metadata_fetch_field.phpt +++ b/ext/mysqli/tests/mysqli_stmt_get_result_metadata_fetch_field.phpt @@ -61,7 +61,7 @@ if (!function_exists('mysqli_stmt_get_result')) require_once("clean_table.inc"); ?> --EXPECTF-- -object(stdClass)#%d (11) { +object(stdClass)#%d (12) { [%u|b%"name"]=> %unicode|string%(2) "id" [%u|b%"orgname"]=> @@ -72,6 +72,8 @@ object(stdClass)#%d (11) { %unicode|string%(4) "test" [%u|b%"def"]=> %unicode|string%(0) "" + [%u|b%"db"]=> + %unicode|string%(4) "test" [%u|b%"max_length"]=> int(0) [%u|b%"length"]=> @@ -85,7 +87,7 @@ object(stdClass)#%d (11) { [%u|b%"decimals"]=> int(0) } -object(stdClass)#%d (11) { +object(stdClass)#%d (12) { [%u|b%"name"]=> %unicode|string%(5) "label" [%u|b%"orgname"]=> @@ -96,6 +98,8 @@ object(stdClass)#%d (11) { %unicode|string%(4) "test" [%u|b%"def"]=> %unicode|string%(0) "" + [%u|b%"db"]=> + %unicode|string%(4) "test" [%u|b%"max_length"]=> int(%d) [%u|b%"length"]=> @@ -109,7 +113,7 @@ object(stdClass)#%d (11) { [%u|b%"decimals"]=> int(0) } -object(stdClass)#%d (11) { +object(stdClass)#%d (12) { [%u|b%"name"]=> %unicode|string%(3) "_id" [%u|b%"orgname"]=> @@ -120,6 +124,8 @@ object(stdClass)#%d (11) { %unicode|string%(0) "" [%u|b%"def"]=> %unicode|string%(0) "" + [%u|b%"db"]=> + %unicode|string%(0) "" [%u|b%"max_length"]=> int(0) [%u|b%"length"]=> @@ -133,7 +139,7 @@ object(stdClass)#%d (11) { [%u|b%"decimals"]=> int(0) } -object(stdClass)#%d (11) { +object(stdClass)#%d (12) { [%u|b%"name"]=> %unicode|string%(8) "___label" [%u|b%"orgname"]=> @@ -144,6 +150,8 @@ object(stdClass)#%d (11) { %unicode|string%(0) "" [%u|b%"def"]=> %unicode|string%(0) "" + [%u|b%"db"]=> + %unicode|string%(0) "" [%u|b%"max_length"]=> int(%d) [%u|b%"length"]=> diff --git a/ext/mysqli/tests/mysqli_stmt_result_metadata.phpt b/ext/mysqli/tests/mysqli_stmt_result_metadata.phpt index f9fd3cf3ca..43ece75e37 100644 --- a/ext/mysqli/tests/mysqli_stmt_result_metadata.phpt +++ b/ext/mysqli/tests/mysqli_stmt_result_metadata.phpt @@ -101,7 +101,7 @@ require_once('skipifconnectfailure.inc'); Warning: mysqli_stmt_result_metadata(): invalid object or resource mysqli_stmt in %s on line %d -object(stdClass)#5 (%d) { +object(stdClass)#5 (12) { [%u|b%"name"]=> %unicode|string%(2) "id" [%u|b%"orgname"]=> @@ -112,6 +112,8 @@ object(stdClass)#5 (%d) { %unicode|string%(4) "test" [%u|b%"def"]=> %unicode|string%(0) "" + [%u|b%"db"]=> + %unicode|string%(4) "test" [%u|b%"max_length"]=> int(0) [%u|b%"length"]=> -- 2.40.0