Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions ext/mysqli/mysqli_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1488,6 +1488,15 @@ PHP_FUNCTION(mysqli_stmt_data_seek)

MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);

if (!stmt->stmt->data || !stmt->stmt->data->result || !stmt->stmt->data->result->stored_data) {
if (hasThis()) {
zend_throw_error(NULL, "mysqli_stmt::data_seek(): No result set associated with the statement");
} else {
zend_throw_error(NULL, "mysqli_stmt_data_seek(): No result set associated with the statement");
}
RETURN_THROWS();
}

mysql_stmt_data_seek(stmt->stmt, offset);
}
/* }}} */
Expand Down
6 changes: 6 additions & 0 deletions ext/mysqli/tests/mysqli_stmt_data_seek.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ require_once 'skipifconnectfailure.inc';
if (true !== ($tmp = mysqli_stmt_execute($stmt)))
printf("[006] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);

try {
mysqli_stmt_data_seek($stmt, 1);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}

$id = null;
if (!mysqli_stmt_bind_result($stmt, $id))
Expand Down Expand Up @@ -82,6 +87,7 @@ require_once 'skipifconnectfailure.inc';
?>
--EXPECT--
mysqli_stmt object is not fully initialized
mysqli_stmt_data_seek(): No result set associated with the statement
int(3)
int(1)
int(1)
Expand Down
Loading