mike mcdowell - 2017-08-09 16:15:44
Using your class mysql2i and results have been very good. We did discover what seems to be an in mysql_result. Our code often has multiple calls to mysql_result to get various fields. For example:
$super = mysql_result($R, 0, 'Super');
$client = mysql_result($R, 0, 'Client');
$book = mysql_result($R, 0, 'Book');
This may not be the most efficient way to get these fields but that is our code. Our problem was that the mysql_result replacement function does not reset the field pointer each time a new call is made. This means that the while loop simply picks up where it left off after the the previous call. Any fields examined trying to find the field name 'Super' from the example above will not be revisited when looking for the field name 'Client', etc. We added a call to mysqli_field_seek to reset the field pointer which seemed to fix the problem we were experiencing:
public static function mysql_result($result,$row,$field=null){
mysqli_data_seek($result,$row);
if( !empty($field) ){
# added next line to reset field pointer in $result
mysqli_field_seek($result,0);
while($finfo = mysqli_fetch_field($result)) {
if( $field == $finfo->name ){
$f = mysqli_fetch_assoc($result);
return $f[$field];
}
}
}
$f = mysqli_fetch_array($result);
return $f[0];
}