Skip to content

Commit 69a3575

Browse files
committed
Implemented FR #39847 (mysqli_fetch_[field|fields|field_direct] need to return db)
1 parent ee62a1a commit 69a3575

13 files changed

+82
-29
lines changed

NEWS

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ PHP NEWS
158158
. mysqlnd: Added named pipes support. FR #48082. (Andrey)
159159
. MySQLi: Added iterator support in MySQLi. mysqli_result implements
160160
Traversable. (Andrey, Johannes)
161+
. MySQLi: Implemented FR #39847 (mysqli_fetch_[field|fields|field_direct]
162+
need to return db). (Kalle)
163+
. PDO_mysql: Implemented FR #47802 (Support for setting character sets in
164+
DSN strings). (Kalle)
161165
. PDO_mysql: Removed support for linking with MySQL client libraries older
162166
than 4.1. (Johannes)
163167

@@ -170,10 +174,6 @@ PHP NEWS
170174
. Added nextRowset support.
171175
. Fixed bug #50755 (PDO DBLIB Fails with OOM).
172176

173-
- Improved PDO MySQL:
174-
. Implemented FR #47802 (Support for setting character sets in DSN strings).
175-
(Kalle)
176-
177177
- Improved Reflection extension: (Johannes)
178178
. Added ReflectionExtension::isTemporary() and
179179
ReflectionExtension::isPersistent() methods.

UPGRADING

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ UPGRADE NOTES - PHP X.Y
163163
present in the result.
164164
- pdo_mysql now supports setting character sets when connecting in the DSN
165165
string.
166+
- mysqli_fetch_[field|fields|field_direct] now returns an additional property
167+
named 'db' that contains the database name of the associated result.
166168

167169

168170
===================================

ext/mysqli/mysqli_api.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,7 @@ static void php_add_field_properties(zval *value, const MYSQL_FIELD *field TSRML
10521052
add_property_string(value, "table",(field->table ? field->table : ""), 1);
10531053
add_property_string(value, "orgtable",(field->org_table ? field->org_table : ""), 1);
10541054
add_property_string(value, "def",(field->def ? field->def : ""), 1);
1055+
add_property_string(value, "db",(field->db ? field->db : ""), 1);
10551056

10561057
add_property_long(value, "max_length", field->max_length);
10571058
add_property_long(value, "length", field->length);

ext/mysqli/tests/047.phpt

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ mysqli_close($link);
6060
=== fetch_fields ===
6161
array(2) {
6262
[0]=>
63-
object(stdClass)#5 (11) {
63+
object(stdClass)#5 (12) {
6464
[%u|b%"name"]=>
6565
%unicode|string%(3) "foo"
6666
[%u|b%"orgname"]=>
@@ -71,6 +71,8 @@ array(2) {
7171
%unicode|string%(13) "test_affected"
7272
[%u|b%"def"]=>
7373
%unicode|string%(0) ""
74+
[%u|b%"db"]=>
75+
%unicode|string%(4) "test"
7476
[%u|b%"max_length"]=>
7577
int(0)
7678
[%u|b%"length"]=>
@@ -85,7 +87,7 @@ array(2) {
8587
int(0)
8688
}
8789
[1]=>
88-
object(stdClass)#6 (11) {
90+
object(stdClass)#6 (12) {
8991
[%u|b%"name"]=>
9092
%unicode|string%(3) "bar"
9193
[%u|b%"orgname"]=>
@@ -96,6 +98,8 @@ array(2) {
9698
%unicode|string%(13) "test_affected"
9799
[%u|b%"def"]=>
98100
%unicode|string%(0) ""
101+
[%u|b%"db"]=>
102+
%unicode|string%(4) "test"
99103
[%u|b%"max_length"]=>
100104
int(0)
101105
[%u|b%"length"]=>
@@ -112,7 +116,7 @@ array(2) {
112116
}
113117

114118
=== fetch_field_direct ===
115-
object(stdClass)#6 (11) {
119+
object(stdClass)#6 (12) {
116120
[%u|b%"name"]=>
117121
%unicode|string%(3) "foo"
118122
[%u|b%"orgname"]=>
@@ -123,6 +127,8 @@ object(stdClass)#6 (11) {
123127
%unicode|string%(13) "test_affected"
124128
[%u|b%"def"]=>
125129
%unicode|string%(0) ""
130+
[%u|b%"db"]=>
131+
%unicode|string%(4) "test"
126132
[%u|b%"max_length"]=>
127133
int(0)
128134
[%u|b%"length"]=>
@@ -136,7 +142,7 @@ object(stdClass)#6 (11) {
136142
[%u|b%"decimals"]=>
137143
int(0)
138144
}
139-
object(stdClass)#6 (11) {
145+
object(stdClass)#6 (12) {
140146
[%u|b%"name"]=>
141147
%unicode|string%(3) "bar"
142148
[%u|b%"orgname"]=>
@@ -147,6 +153,8 @@ object(stdClass)#6 (11) {
147153
%unicode|string%(13) "test_affected"
148154
[%u|b%"def"]=>
149155
%unicode|string%(0) ""
156+
[%u|b%"db"]=>
157+
%unicode|string%(4) "test"
150158
[%u|b%"max_length"]=>
151159
int(0)
152160
[%u|b%"length"]=>
@@ -162,7 +170,7 @@ object(stdClass)#6 (11) {
162170
}
163171

164172
=== fetch_field ===
165-
object(stdClass)#6 (11) {
173+
object(stdClass)#6 (12) {
166174
[%u|b%"name"]=>
167175
%unicode|string%(3) "foo"
168176
[%u|b%"orgname"]=>
@@ -173,6 +181,8 @@ object(stdClass)#6 (11) {
173181
%unicode|string%(13) "test_affected"
174182
[%u|b%"def"]=>
175183
%unicode|string%(0) ""
184+
[%u|b%"db"]=>
185+
%unicode|string%(4) "test"
176186
[%u|b%"max_length"]=>
177187
int(0)
178188
[%u|b%"length"]=>
@@ -186,7 +196,7 @@ object(stdClass)#6 (11) {
186196
[%u|b%"decimals"]=>
187197
int(0)
188198
}
189-
object(stdClass)#5 (11) {
199+
object(stdClass)#5 (12) {
190200
[%u|b%"name"]=>
191201
%unicode|string%(3) "bar"
192202
[%u|b%"orgname"]=>
@@ -197,6 +207,8 @@ object(stdClass)#5 (11) {
197207
%unicode|string%(13) "test_affected"
198208
[%u|b%"def"]=>
199209
%unicode|string%(0) ""
210+
[%u|b%"db"]=>
211+
%unicode|string%(4) "test"
200212
[%u|b%"max_length"]=>
201213
int(0)
202214
[%u|b%"length"]=>

ext/mysqli/tests/mysqli_fetch_field.phpt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ require_once('skipifconnectfailure.inc');
7979
require_once("clean_table.inc");
8080
?>
8181
--EXPECTF--
82-
object(stdClass)#%d (11) {
82+
object(stdClass)#%d (12) {
8383
[%u|b%"name"]=>
8484
%unicode|string%(2) "ID"
8585
[%u|b%"orgname"]=>
@@ -90,6 +90,8 @@ object(stdClass)#%d (11) {
9090
%unicode|string%(4) "test"
9191
[%u|b%"def"]=>
9292
%unicode|string%(0) ""
93+
[%u|b%"db"]=>
94+
%unicode|string%(4) "test"
9395
[%u|b%"max_length"]=>
9496
int(1)
9597
[%u|b%"length"]=>
@@ -103,7 +105,7 @@ object(stdClass)#%d (11) {
103105
[%u|b%"decimals"]=>
104106
int(0)
105107
}
106-
object(stdClass)#%d (11) {
108+
object(stdClass)#%d (12) {
107109
[%u|b%"name"]=>
108110
%unicode|string%(5) "label"
109111
[%u|b%"orgname"]=>
@@ -114,6 +116,8 @@ object(stdClass)#%d (11) {
114116
%unicode|string%(4) "test"
115117
[%u|b%"def"]=>
116118
%unicode|string%(0) ""
119+
[%u|b%"db"]=>
120+
%unicode|string%(4) "test"
117121
[%u|b%"max_length"]=>
118122
int(%d)
119123
[%u|b%"length"]=>
@@ -134,7 +138,7 @@ array(1) {
134138
[%u|b%"_default_test"]=>
135139
%unicode|string%(1) "2"
136140
}
137-
object(stdClass)#%d (11) {
141+
object(stdClass)#%d (12) {
138142
[%u|b%"name"]=>
139143
%unicode|string%(13) "_default_test"
140144
[%u|b%"orgname"]=>
@@ -145,6 +149,8 @@ object(stdClass)#%d (11) {
145149
%unicode|string%(4) "test"
146150
[%u|b%"def"]=>
147151
%unicode|string%(0) ""
152+
[%u|b%"db"]=>
153+
%unicode|string%(4) "test"
148154
[%u|b%"max_length"]=>
149155
int(1)
150156
[%u|b%"length"]=>

ext/mysqli/tests/mysqli_fetch_field_direct.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ require_once('skipifconnectfailure.inc');
4747
--EXPECTF--
4848
Warning: mysqli_fetch_field_direct(): Field offset is invalid for resultset in %s on line %d
4949
bool(false)
50-
object(stdClass)#%d (11) {
50+
object(stdClass)#%d (12) {
5151
[%u|b%"name"]=>
5252
%unicode|string%(2) "ID"
5353
[%u|b%"orgname"]=>
@@ -58,6 +58,8 @@ object(stdClass)#%d (11) {
5858
%unicode|string%(4) "test"
5959
[%u|b%"def"]=>
6060
%unicode|string%(0) ""
61+
[%u|b%"db"]=>
62+
%unicode|string%(4) "test"
6163
[%u|b%"max_length"]=>
6264
int(%d)
6365
[%u|b%"length"]=>

ext/mysqli/tests/mysqli_fetch_field_direct_oo.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ require_once('skipifconnectfailure.inc');
5656
--EXPECTF--
5757
Warning: mysqli_result::fetch_field_direct(): Field offset is invalid for resultset in %s on line %d
5858
bool(false)
59-
object(stdClass)#%d (11) {
59+
object(stdClass)#%d (12) {
6060
[%u|b%"name"]=>
6161
%unicode|string%(2) "ID"
6262
[%u|b%"orgname"]=>
@@ -67,6 +67,8 @@ object(stdClass)#%d (11) {
6767
%unicode|string%(4) "test"
6868
[%u|b%"def"]=>
6969
%unicode|string%(0) ""
70+
[%u|b%"db"]=>
71+
%unicode|string%(4) "test"
7072
[%u|b%"max_length"]=>
7173
int(%d)
7274
[%u|b%"length"]=>

ext/mysqli/tests/mysqli_fetch_field_oo.phpt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ require_once('skipifconnectfailure.inc');
6363
require_once("clean_table.inc");
6464
?>
6565
--EXPECTF--
66-
object(stdClass)#%d (11) {
66+
object(stdClass)#%d (12) {
6767
[%u|b%"name"]=>
6868
%unicode|string%(2) "ID"
6969
[%u|b%"orgname"]=>
@@ -74,6 +74,8 @@ object(stdClass)#%d (11) {
7474
%unicode|string%(4) "test"
7575
[%u|b%"def"]=>
7676
%unicode|string%(0) ""
77+
[%u|b%"db"]=>
78+
%unicode|string%(4) "test"
7779
[%u|b%"max_length"]=>
7880
int(1)
7981
[%u|b%"length"]=>
@@ -87,7 +89,7 @@ object(stdClass)#%d (11) {
8789
[%u|b%"decimals"]=>
8890
int(0)
8991
}
90-
object(stdClass)#%d (11) {
92+
object(stdClass)#%d (12) {
9193
[%u|b%"name"]=>
9294
%unicode|string%(5) "label"
9395
[%u|b%"orgname"]=>
@@ -98,6 +100,8 @@ object(stdClass)#%d (11) {
98100
%unicode|string%(4) "test"
99101
[%u|b%"def"]=>
100102
%unicode|string%(0) ""
103+
[%u|b%"db"]=>
104+
%unicode|string%(4) "test"
101105
[%u|b%"max_length"]=>
102106
int(%d)
103107
[%u|b%"length"]=>

ext/mysqli/tests/mysqli_fetch_fields.phpt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ require_once('skipifconnectfailure.inc');
6060
require_once("clean_table.inc");
6161
?>
6262
--EXPECTF--
63-
object(stdClass)#%d (11) {
63+
object(stdClass)#%d (12) {
6464
[%u|b%"name"]=>
6565
%unicode|string%(2) "ID"
6666
[%u|b%"orgname"]=>
@@ -71,6 +71,8 @@ object(stdClass)#%d (11) {
7171
%unicode|string%(4) "test"
7272
[%u|b%"def"]=>
7373
%unicode|string%(0) ""
74+
[%u|b%"db"]=>
75+
%unicode|string%(4) "test"
7476
[%u|b%"max_length"]=>
7577
int(1)
7678
[%u|b%"length"]=>
@@ -84,7 +86,7 @@ object(stdClass)#%d (11) {
8486
[%u|b%"decimals"]=>
8587
int(0)
8688
}
87-
object(stdClass)#%d (11) {
89+
object(stdClass)#%d (12) {
8890
[%u|b%"name"]=>
8991
%unicode|string%(5) "label"
9092
[%u|b%"orgname"]=>
@@ -95,6 +97,8 @@ object(stdClass)#%d (11) {
9597
%unicode|string%(4) "test"
9698
[%u|b%"def"]=>
9799
%unicode|string%(0) ""
100+
[%u|b%"db"]=>
101+
%unicode|string%(4) "test"
98102
[%u|b%"max_length"]=>
99103
int(1)
100104
[%u|b%"length"]=>

ext/mysqli/tests/mysqli_field_seek.phpt

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ require_once('skipifconnectfailure.inc');
122122
--EXPECTF--
123123
Warning: mysqli_field_seek(): Invalid field offset in %s on line %d
124124
bool(false)
125-
object(stdClass)#%d (11) {
125+
object(stdClass)#%d (12) {
126126
[%u|b%"name"]=>
127127
%unicode|string%(2) "id"
128128
[%u|b%"orgname"]=>
@@ -133,6 +133,8 @@ object(stdClass)#%d (11) {
133133
%unicode|string%(4) "test"
134134
[%u|b%"def"]=>
135135
%unicode|string%(0) ""
136+
[%u|b%"db"]=>
137+
%unicode|string%(4) "test"
136138
[%u|b%"max_length"]=>
137139
int(0)
138140
[%u|b%"length"]=>
@@ -147,7 +149,7 @@ object(stdClass)#%d (11) {
147149
int(0)
148150
}
149151
bool(true)
150-
object(stdClass)#%d (11) {
152+
object(stdClass)#%d (12) {
151153
[%u|b%"name"]=>
152154
%unicode|string%(2) "id"
153155
[%u|b%"orgname"]=>
@@ -158,6 +160,8 @@ object(stdClass)#%d (11) {
158160
%unicode|string%(4) "test"
159161
[%u|b%"def"]=>
160162
%unicode|string%(0) ""
163+
[%u|b%"db"]=>
164+
%unicode|string%(4) "test"
161165
[%u|b%"max_length"]=>
162166
int(0)
163167
[%u|b%"length"]=>
@@ -172,7 +176,7 @@ object(stdClass)#%d (11) {
172176
int(0)
173177
}
174178
bool(true)
175-
object(stdClass)#%d (11) {
179+
object(stdClass)#%d (12) {
176180
[%u|b%"name"]=>
177181
%unicode|string%(5) "label"
178182
[%u|b%"orgname"]=>
@@ -183,6 +187,8 @@ object(stdClass)#%d (11) {
183187
%unicode|string%(4) "test"
184188
[%u|b%"def"]=>
185189
%unicode|string%(0) ""
190+
[%u|b%"db"]=>
191+
%unicode|string%(4) "test"
186192
[%u|b%"max_length"]=>
187193
int(%d)
188194
[%u|b%"length"]=>
@@ -205,7 +211,7 @@ bool(false)
205211
Warning: mysqli_field_seek(): Invalid field offset in %s on line %d
206212
bool(false)
207213
bool(true)
208-
object(stdClass)#3 (11) {
214+
object(stdClass)#3 (12) {
209215
[%u|b%"name"]=>
210216
%unicode|string%(5) "_null"
211217
[%u|b%"orgname"]=>
@@ -216,6 +222,8 @@ object(stdClass)#3 (11) {
216222
%unicode|string%(0) ""
217223
[%u|b%"def"]=>
218224
%unicode|string%(0) ""
225+
[%u|b%"db"]=>
226+
%unicode|string%(0) ""
219227
[%u|b%"max_length"]=>
220228
int(0)
221229
[%u|b%"length"]=>

0 commit comments

Comments
 (0)