Skip to content

Commit 05ad183

Browse files
committed
It can return float as well
1 parent b892815 commit 05ad183

File tree

3 files changed

+28
-15
lines changed

3 files changed

+28
-15
lines changed

ext/mysqli/mysqli.stub.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ public function fetch_row() {}
429429
/**
430430
* @alias mysqli_fetch_column
431431
*/
432-
public function fetch_column(int $column = 0): null|int|string|false {}
432+
public function fetch_column(int $column = 0): null|int|float|string|false {}
433433

434434
/**
435435
* @return bool
@@ -670,7 +670,7 @@ function mysqli_fetch_object(mysqli_result $result, string $class = "stdClass",
670670

671671
function mysqli_fetch_row(mysqli_result $result): array|null|false {}
672672

673-
function mysqli_fetch_column(mysqli_result $result, int $column = 0): null|int|string|false {}
673+
function mysqli_fetch_column(mysqli_result $result, int $column = 0): null|int|float|string|false {}
674674

675675
function mysqli_field_count(mysqli $mysql): int {}
676676

ext/mysqli/mysqli_arginfo.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 744c59d0ae28d46f99e478c903cdf9741f97d134 */
2+
* Stub hash: 8a095c856517b625ec524a6c26a18492bba067f9 */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mysqli_affected_rows, 0, 1, MAY_BE_LONG|MAY_BE_STRING)
55
ZEND_ARG_OBJ_INFO(0, mysql, mysqli, 0)
@@ -115,7 +115,7 @@ ZEND_END_ARG_INFO()
115115

116116
#define arginfo_mysqli_fetch_row arginfo_mysqli_fetch_assoc
117117

118-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mysqli_fetch_column, 0, 1, MAY_BE_NULL|MAY_BE_LONG|MAY_BE_STRING|MAY_BE_FALSE)
118+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mysqli_fetch_column, 0, 1, MAY_BE_NULL|MAY_BE_LONG|MAY_BE_DOUBLE|MAY_BE_STRING|MAY_BE_FALSE)
119119
ZEND_ARG_OBJ_INFO(0, result, mysqli_result, 0)
120120
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, column, IS_LONG, 0, "0")
121121
ZEND_END_ARG_INFO()
@@ -614,7 +614,7 @@ ZEND_END_ARG_INFO()
614614

615615
#define arginfo_class_mysqli_result_fetch_row arginfo_class_mysqli_character_set_name
616616

617-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_mysqli_result_fetch_column, 0, 0, MAY_BE_NULL|MAY_BE_LONG|MAY_BE_STRING|MAY_BE_FALSE)
617+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_mysqli_result_fetch_column, 0, 0, MAY_BE_NULL|MAY_BE_LONG|MAY_BE_DOUBLE|MAY_BE_STRING|MAY_BE_FALSE)
618618
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, column, IS_LONG, 0, "0")
619619
ZEND_END_ARG_INFO()
620620

ext/mysqli/tests/mysqli_fetch_column.phpt

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,28 @@ $res = mysqli_query($link, "SELECT
6464
print "[007]\n";
6565
var_dump(mysqli_fetch_column($res, 4));
6666

67-
$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id LIMIT 1");
67+
$res = mysqli_query($link, "SELECT
68+
1.42 AS a
69+
");
6870
print "[008]\n";
71+
var_dump(mysqli_fetch_column($res, 0));
72+
73+
$res = mysqli_query($link, "SELECT
74+
1.42E0 AS a
75+
");
76+
print "[009]\n";
77+
var_dump(mysqli_fetch_column($res, 0));
78+
79+
$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id LIMIT 1");
80+
print "[010]\n";
6981
try {
7082
var_dump(mysqli_fetch_column($res, -1));
7183
} catch (\ValueError $e) {
7284
echo $e->getMessage(), \PHP_EOL;
7385
}
7486

7587
$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id LIMIT 1");
76-
print "[009]\n";
88+
print "[011]\n";
7789
try {
7890
var_dump(mysqli_fetch_column($res, 2));
7991
} catch (\ValueError $e) {
@@ -89,15 +101,13 @@ try {
89101

90102
$res = $link->query("SELECT id, label FROM test ORDER BY id LIMIT 2");
91103

92-
print "[010]\n";
104+
print "[012]\n";
93105
var_dump($res->fetch_column());
94106

95-
print "[011]\n";
107+
print "[013]\n";
96108
var_dump($res->fetch_column(1));
97109

98110
mysqli_close($link);
99-
100-
print "done!";
101111
?>
102112
--CLEAN--
103113
<?php
@@ -119,12 +129,15 @@ NULL
119129
[007]
120130
int(1)
121131
[008]
122-
mysqli_fetch_column(): Argument #2 ($column) must be greater than or equal to 0
132+
string(4) "1.42"
123133
[009]
134+
float(1.42)
135+
[010]
136+
mysqli_fetch_column(): Argument #2 ($column) must be greater than or equal to 0
137+
[011]
124138
mysqli_fetch_column(): Argument #2 ($column) must be less than the number of fields for this result set
125139
mysqli_result object is already closed
126-
[010]
140+
[012]
127141
int(1)
128-
[011]
142+
[013]
129143
string(1) "b"
130-
done!

0 commit comments

Comments
 (0)