Skip to content

Commit

Permalink
Implemented FR #39847 (mysqli_fetch_[field|fields|field_direct] need …
Browse files Browse the repository at this point in the history
…to return db)
  • Loading branch information
KalleZ committed Jan 7, 2011
1 parent ee62a1a commit 69a3575
Show file tree
Hide file tree
Showing 13 changed files with 82 additions and 29 deletions.
8 changes: 4 additions & 4 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -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.


===================================
Expand Down
1 change: 1 addition & 0 deletions ext/mysqli/mysqli_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
24 changes: 18 additions & 6 deletions ext/mysqli/tests/047.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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"]=>
Expand All @@ -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"]=>
Expand All @@ -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"]=>
Expand All @@ -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"]=>
Expand All @@ -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"]=>
Expand All @@ -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"]=>
Expand All @@ -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"]=>
Expand All @@ -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"]=>
Expand All @@ -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"]=>
Expand All @@ -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"]=>
Expand All @@ -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"]=>
Expand All @@ -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"]=>
Expand Down
12 changes: 9 additions & 3 deletions ext/mysqli/tests/mysqli_fetch_field.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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"]=>
Expand All @@ -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"]=>
Expand All @@ -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"]=>
Expand All @@ -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"]=>
Expand All @@ -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"]=>
Expand All @@ -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"]=>
Expand Down
4 changes: 3 additions & 1 deletion ext/mysqli/tests/mysqli_fetch_field_direct.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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"]=>
Expand All @@ -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"]=>
Expand Down
4 changes: 3 additions & 1 deletion ext/mysqli/tests/mysqli_fetch_field_direct_oo.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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"]=>
Expand All @@ -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"]=>
Expand Down
8 changes: 6 additions & 2 deletions ext/mysqli/tests/mysqli_fetch_field_oo.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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"]=>
Expand All @@ -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"]=>
Expand All @@ -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"]=>
Expand All @@ -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"]=>
Expand Down
8 changes: 6 additions & 2 deletions ext/mysqli/tests/mysqli_fetch_fields.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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"]=>
Expand All @@ -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"]=>
Expand All @@ -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"]=>
Expand All @@ -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"]=>
Expand Down
16 changes: 12 additions & 4 deletions ext/mysqli/tests/mysqli_field_seek.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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"]=>
Expand All @@ -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"]=>
Expand All @@ -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"]=>
Expand All @@ -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"]=>
Expand All @@ -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"]=>
Expand All @@ -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"]=>
Expand All @@ -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"]=>
Expand All @@ -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"]=>
Expand Down
4 changes: 3 additions & 1 deletion ext/mysqli/tests/mysqli_field_tell.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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"]=>
Expand All @@ -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"]=>
Expand Down
Loading

0 comments on commit 69a3575

Please sign in to comment.