Skip to content

Commit 10b5b11

Browse files
committed
use ValueError for this instead
1 parent 27c025f commit 10b5b11

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

ext/odbc/php_odbc.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,8 +1343,10 @@ static void php_odbc_fetch(INTERNAL_FUNCTION_PARAMETERS, bool return_array, php_
13431343
CHECK_ODBC_RESULT(result);
13441344

13451345
if (!pv_row_is_null && pv_row < 1) {
1346-
php_error_docref(NULL, E_WARNING, "Last argument ($row) must be greater than or equal to 1");
1347-
RETURN_FALSE;
1346+
/* row arg no differs between callers */
1347+
zend_argument_value_error(pv_res_arr == return_value ? 2 : 3,
1348+
"must be greater than or equal to 1");
1349+
RETURN_THROWS();
13481350
}
13491351

13501352
if (result->numcols == 0) {

ext/odbc/tests/odbc_fetch_row_001.phpt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ odbc_exec($conn, 'INSERT INTO fetch_row VALUES (1), (2)');
1717

1818
$res = odbc_exec($conn, 'SELECT * FROM fetch_row');
1919

20-
var_dump(odbc_fetch_row($res, 0));
20+
try {
21+
var_dump(odbc_fetch_row($res, 0));
22+
} catch (\ValueError $e) {
23+
echo $e->getMessage() . \PHP_EOL;
24+
}
2125

2226
var_dump(odbc_fetch_row($res, null));
2327
var_dump(odbc_result($res, 'test'));
@@ -39,9 +43,8 @@ require 'config.inc';
3943
$conn = odbc_connect($dsn, $user, $pass);
4044
odbc_exec($conn, 'DROP TABLE fetch_row');
4145
?>
42-
--EXPECTF--
43-
Warning: odbc_fetch_row(): Last argument ($row) must be greater than or equal to 1 in %s on line %d
44-
bool(false)
46+
--EXPECT--
47+
odbc_fetch_row(): Argument #2 ($row) must be greater than or equal to 1
4548
bool(true)
4649
string(1) "1"
4750
bool(true)

0 commit comments

Comments
 (0)