ConFoo Montreal 2026: Call for Papers

Voting

: max(nine, one)?
(Example: nine)

The Note You're Voting On

tuxedobob
12 years ago
Converting an old project from using the mysql extension to the mysqli extension, I found the most annoying change to be the lack of a corresponding mysql_result function in mysqli. While mysql_result is a generally terrible function, it was useful for fetching a single result field *value* from a result set (for example, if looking up a user's ID).

The behavior of mysql_result is approximated here, though you may want to name it something other than mysqli_result so as to avoid thinking it's an actual, built-in function.

<?php
function mysqli_result($res, $row, $field=0) {
$res->data_seek($row);
$datarow = $res->fetch_array();
return
$datarow[$field];
}
?>

Implementing it via the OO interface is left as an exercise to the reader.

<< Back to user notes page

To Top