Aligning the behaviour of fetch_field and field_seek.
MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, "mysqli_result", MYSQLI_STATUS_VALID);
if ((uint32_t)fieldnr >= mysql_num_fields(result)) {
- // TODO ValueError?
- php_error_docref(NULL, E_WARNING, "Invalid field offset");
- RETURN_FALSE;
+ zend_argument_value_error(ERROR_ARG_POS(2), "must be less than the number of fields for this result set");
+ RETURN_THROWS();
}
mysql_field_seek(result, fieldnr);
}
var_dump(mysqli_field_tell($res));
- var_dump(mysqli_field_seek($res, 2));
+ try {
+ var_dump(mysqli_field_seek($res, 2));
+ } catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+ }
var_dump(mysqli_fetch_field($res));
mysqli_free_result($res);
int(0)
}
int(2)
-
-Warning: mysqli_field_seek(): Invalid field offset in %s on line %d
-bool(false)
+mysqli_field_seek(): Argument #2 ($field_nr) must be less than the number of fields for this result set
bool(false)
bool(true)
object(stdClass)#%d (13) {
var_dump(mysqli_fetch_field($res));
var_dump(mysqli_field_tell($res));
- var_dump(mysqli_field_seek($res, 2));
+ try {
+ var_dump(mysqli_field_seek($res, 2));
+ } catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+ }
var_dump(mysqli_field_tell($res));
try {
}
bool(false)
int(1)
-
-Warning: mysqli_field_seek(): Invalid field offset in %s on line %d
-bool(false)
+mysqli_field_seek(): Argument #2 ($field_nr) must be less than the number of fields for this result set
int(1)
mysqli_field_seek(): Argument #2 ($field_nr) must be greater than or equal to 0
int(1)