note 109782 added to class.mysqli-result
| From: | tuxedobob | Date: | Mon, 20 Aug 2012 21:35:04 +0000 |
| Subject: | note 109782 added to class.mysqli-result | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-190143@lists.php.net to get a copy of this message | ||
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.
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.
----
Server IP: 192.41.42.26
Probable Submitter: 76.119.176.226
----
Manual Page -- http://www.php.net/manual/en/class.mysqli-result.php
Edit -- https://master.php.net/note/edit/109782
Del: integrated -- https://master.php.net/note/delete/109782/integrated
Del: useless -- https://master.php.net/note/delete/109782/useless
Del: bad code -- https://master.php.net/note/delete/109782/bad+code
Del: spam -- https://master.php.net/note/delete/109782/spam
Del: non-english -- https://master.php.net/note/delete/109782/non-english
Del: in docs -- https://master.php.net/note/delete/109782/in+docs
Del: other reasons-- https://master.php.net/note/delete/109782
Reject -- https://master.php.net/note/reject/109782
Search -- https://master.php.net/manage/user-notes.php