Skip to content

Commit

Permalink
Added 'catalog' to the field fetching functions in mysqli (Thanks to …
Browse files Browse the repository at this point in the history
…Johannes for the headsup)
  • Loading branch information
KalleZ committed Jan 17, 2011
1 parent dc8da85 commit 5ba90ae
Show file tree
Hide file tree
Showing 13 changed files with 76 additions and 29 deletions.
2 changes: 0 additions & 2 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,6 @@ 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: Removed support for linking with MySQL client libraries older
than 4.1. (Johannes)

Expand Down
2 changes: 0 additions & 2 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,6 @@ UPGRADE NOTES - PHP X.Y
strings. This breaks code that iterated the resulting stream array using a
numeric index, but makes easier to identify which of the passed streams are
present in the result.
- 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 @@ -1057,6 +1057,7 @@ static void php_add_field_properties(zval *value, const MYSQL_FIELD *field TSRML
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_string(value, "catalog",(field->catalog ? field->catalog : ""), 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 (12) {
object(stdClass)#5 (13) {
[%u|b%"name"]=>
%unicode|string%(3) "foo"
[%u|b%"orgname"]=>
Expand All @@ -73,6 +73,8 @@ array(2) {
%unicode|string%(0) ""
[%u|b%"db"]=>
%unicode|string%(4) "test"
[%u|b%"catalog"]=>
%unicode|string%(3) "def"
[%u|b%"max_length"]=>
int(0)
[%u|b%"length"]=>
Expand All @@ -87,7 +89,7 @@ array(2) {
int(0)
}
[1]=>
object(stdClass)#6 (12) {
object(stdClass)#6 (13) {
[%u|b%"name"]=>
%unicode|string%(3) "bar"
[%u|b%"orgname"]=>
Expand All @@ -100,6 +102,8 @@ array(2) {
%unicode|string%(0) ""
[%u|b%"db"]=>
%unicode|string%(4) "test"
[%u|b%"catalog"]=>
%unicode|string%(3) "def"
[%u|b%"max_length"]=>
int(0)
[%u|b%"length"]=>
Expand All @@ -116,7 +120,7 @@ array(2) {
}

=== fetch_field_direct ===
object(stdClass)#6 (12) {
object(stdClass)#6 (13) {
[%u|b%"name"]=>
%unicode|string%(3) "foo"
[%u|b%"orgname"]=>
Expand All @@ -129,6 +133,8 @@ object(stdClass)#6 (12) {
%unicode|string%(0) ""
[%u|b%"db"]=>
%unicode|string%(4) "test"
[%u|b%"catalog"]=>
%unicode|string%(3) "def"
[%u|b%"max_length"]=>
int(0)
[%u|b%"length"]=>
Expand All @@ -142,7 +148,7 @@ object(stdClass)#6 (12) {
[%u|b%"decimals"]=>
int(0)
}
object(stdClass)#6 (12) {
object(stdClass)#6 (13) {
[%u|b%"name"]=>
%unicode|string%(3) "bar"
[%u|b%"orgname"]=>
Expand All @@ -155,6 +161,8 @@ object(stdClass)#6 (12) {
%unicode|string%(0) ""
[%u|b%"db"]=>
%unicode|string%(4) "test"
[%u|b%"catalog"]=>
%unicode|string%(3) "def"
[%u|b%"max_length"]=>
int(0)
[%u|b%"length"]=>
Expand All @@ -170,7 +178,7 @@ object(stdClass)#6 (12) {
}

=== fetch_field ===
object(stdClass)#6 (12) {
object(stdClass)#6 (13) {
[%u|b%"name"]=>
%unicode|string%(3) "foo"
[%u|b%"orgname"]=>
Expand All @@ -183,6 +191,8 @@ object(stdClass)#6 (12) {
%unicode|string%(0) ""
[%u|b%"db"]=>
%unicode|string%(4) "test"
[%u|b%"catalog"]=>
%unicode|string%(3) "def"
[%u|b%"max_length"]=>
int(0)
[%u|b%"length"]=>
Expand All @@ -196,7 +206,7 @@ object(stdClass)#6 (12) {
[%u|b%"decimals"]=>
int(0)
}
object(stdClass)#5 (12) {
object(stdClass)#5 (13) {
[%u|b%"name"]=>
%unicode|string%(3) "bar"
[%u|b%"orgname"]=>
Expand All @@ -209,6 +219,8 @@ object(stdClass)#5 (12) {
%unicode|string%(0) ""
[%u|b%"db"]=>
%unicode|string%(4) "test"
[%u|b%"catalog"]=>
%unicode|string%(3) "def"
[%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 (12) {
object(stdClass)#%d (13) {
[%u|b%"name"]=>
%unicode|string%(2) "ID"
[%u|b%"orgname"]=>
Expand All @@ -92,6 +92,8 @@ object(stdClass)#%d (12) {
%unicode|string%(0) ""
[%u|b%"db"]=>
%unicode|string%(4) "test"
[%u|b%"catalog"]=>
%unicode|string%(3) "def"
[%u|b%"max_length"]=>
int(1)
[%u|b%"length"]=>
Expand All @@ -105,7 +107,7 @@ object(stdClass)#%d (12) {
[%u|b%"decimals"]=>
int(0)
}
object(stdClass)#%d (12) {
object(stdClass)#%d (13) {
[%u|b%"name"]=>
%unicode|string%(5) "label"
[%u|b%"orgname"]=>
Expand All @@ -118,6 +120,8 @@ object(stdClass)#%d (12) {
%unicode|string%(0) ""
[%u|b%"db"]=>
%unicode|string%(4) "test"
[%u|b%"catalog"]=>
%unicode|string%(3) "def"
[%u|b%"max_length"]=>
int(%d)
[%u|b%"length"]=>
Expand All @@ -138,7 +142,7 @@ array(1) {
[%u|b%"_default_test"]=>
%unicode|string%(1) "2"
}
object(stdClass)#%d (12) {
object(stdClass)#%d (13) {
[%u|b%"name"]=>
%unicode|string%(13) "_default_test"
[%u|b%"orgname"]=>
Expand All @@ -151,6 +155,8 @@ object(stdClass)#%d (12) {
%unicode|string%(0) ""
[%u|b%"db"]=>
%unicode|string%(4) "test"
[%u|b%"catalog"]=>
%unicode|string%(3) "def"
[%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 (12) {
object(stdClass)#%d (13) {
[%u|b%"name"]=>
%unicode|string%(2) "ID"
[%u|b%"orgname"]=>
Expand All @@ -60,6 +60,8 @@ object(stdClass)#%d (12) {
%unicode|string%(0) ""
[%u|b%"db"]=>
%unicode|string%(4) "test"
[%u|b%"catalog"]=>
%unicode|string%(3) "def"
[%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 (12) {
object(stdClass)#%d (13) {
[%u|b%"name"]=>
%unicode|string%(2) "ID"
[%u|b%"orgname"]=>
Expand All @@ -69,6 +69,8 @@ object(stdClass)#%d (12) {
%unicode|string%(0) ""
[%u|b%"db"]=>
%unicode|string%(4) "test"
[%u|b%"catalog"]=>
%unicode|string%(3) "def"
[%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 (12) {
object(stdClass)#%d (13) {
[%u|b%"name"]=>
%unicode|string%(2) "ID"
[%u|b%"orgname"]=>
Expand All @@ -76,6 +76,8 @@ object(stdClass)#%d (12) {
%unicode|string%(0) ""
[%u|b%"db"]=>
%unicode|string%(4) "test"
[%u|b%"catalog"]=>
%unicode|string%(3) "def"
[%u|b%"max_length"]=>
int(1)
[%u|b%"length"]=>
Expand All @@ -89,7 +91,7 @@ object(stdClass)#%d (12) {
[%u|b%"decimals"]=>
int(0)
}
object(stdClass)#%d (12) {
object(stdClass)#%d (13) {
[%u|b%"name"]=>
%unicode|string%(5) "label"
[%u|b%"orgname"]=>
Expand All @@ -102,6 +104,8 @@ object(stdClass)#%d (12) {
%unicode|string%(0) ""
[%u|b%"db"]=>
%unicode|string%(4) "test"
[%u|b%"catalog"]=>
%unicode|string%(3) "def"
[%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 (12) {
object(stdClass)#%d (13) {
[%u|b%"name"]=>
%unicode|string%(2) "ID"
[%u|b%"orgname"]=>
Expand All @@ -73,6 +73,8 @@ object(stdClass)#%d (12) {
%unicode|string%(0) ""
[%u|b%"db"]=>
%unicode|string%(4) "test"
[%u|b%"catalog"]=>
%unicode|string%(3) "def"
[%u|b%"max_length"]=>
int(1)
[%u|b%"length"]=>
Expand All @@ -86,7 +88,7 @@ object(stdClass)#%d (12) {
[%u|b%"decimals"]=>
int(0)
}
object(stdClass)#%d (12) {
object(stdClass)#%d (13) {
[%u|b%"name"]=>
%unicode|string%(5) "label"
[%u|b%"orgname"]=>
Expand All @@ -99,6 +101,8 @@ object(stdClass)#%d (12) {
%unicode|string%(0) ""
[%u|b%"db"]=>
%unicode|string%(4) "test"
[%u|b%"catalog"]=>
%unicode|string%(3) "def"
[%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 (12) {
object(stdClass)#%d (13) {
[%u|b%"name"]=>
%unicode|string%(2) "id"
[%u|b%"orgname"]=>
Expand All @@ -135,6 +135,8 @@ object(stdClass)#%d (12) {
%unicode|string%(0) ""
[%u|b%"db"]=>
%unicode|string%(4) "test"
[%u|b%"catalog"]=>
%unicode|string%(3) "def"
[%u|b%"max_length"]=>
int(0)
[%u|b%"length"]=>
Expand All @@ -149,7 +151,7 @@ object(stdClass)#%d (12) {
int(0)
}
bool(true)
object(stdClass)#%d (12) {
object(stdClass)#%d (13) {
[%u|b%"name"]=>
%unicode|string%(2) "id"
[%u|b%"orgname"]=>
Expand All @@ -162,6 +164,8 @@ object(stdClass)#%d (12) {
%unicode|string%(0) ""
[%u|b%"db"]=>
%unicode|string%(4) "test"
[%u|b%"catalog"]=>
%unicode|string%(3) "def"
[%u|b%"max_length"]=>
int(0)
[%u|b%"length"]=>
Expand All @@ -176,7 +180,7 @@ object(stdClass)#%d (12) {
int(0)
}
bool(true)
object(stdClass)#%d (12) {
object(stdClass)#%d (13) {
[%u|b%"name"]=>
%unicode|string%(5) "label"
[%u|b%"orgname"]=>
Expand All @@ -189,6 +193,8 @@ object(stdClass)#%d (12) {
%unicode|string%(0) ""
[%u|b%"db"]=>
%unicode|string%(4) "test"
[%u|b%"catalog"]=>
%unicode|string%(3) "def"
[%u|b%"max_length"]=>
int(%d)
[%u|b%"length"]=>
Expand All @@ -211,7 +217,7 @@ bool(false)
Warning: mysqli_field_seek(): Invalid field offset in %s on line %d
bool(false)
bool(true)
object(stdClass)#3 (12) {
object(stdClass)#3 (13) {
[%u|b%"name"]=>
%unicode|string%(5) "_null"
[%u|b%"orgname"]=>
Expand All @@ -224,6 +230,8 @@ object(stdClass)#3 (12) {
%unicode|string%(0) ""
[%u|b%"db"]=>
%unicode|string%(0) ""
[%u|b%"catalog"]=>
%unicode|string%(3) "def"
[%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 (12) {
object(stdClass)#%d (13) {
[%u|b%"name"]=>
%unicode|string%(2) "id"
[%u|b%"orgname"]=>
Expand All @@ -77,6 +77,8 @@ object(stdClass)#%d (12) {
%unicode|string%(0) ""
[%u|b%"db"]=>
%unicode|string%(4) "test"
[%u|b%"catalog"]=>
%unicode|string%(3) "def"
[%u|b%"max_length"]=>
int(0)
[%u|b%"length"]=>
Expand Down
Loading

0 comments on commit 5ba90ae

Please sign in to comment.