mysql_field_seek()
MYSQL_FIELD_OFFSET mysql_field_seek(MYSQL_RES *result,
MYSQL_FIELD_OFFSET offset)Use this function in conjunction with
mysql_fetch_field() to change the current
field being fetched to the one specified in the second argument of
this function. The function returns the offset of the field that was
current before the function was invoked. A reference to the results
set must be passed as the first argument. Here is an example:
...
mysql_query(mysql, sql_stmnt);
MYSQL_FIELD_OFFSET offset = 2;
mysql_field_seek(result, offset);
while((field = mysql_fetch_field(result)) != NULL)
{
printf("%d: %s \n", mysql_field_tell(result), field->name);
}
...Using mysql_field_seek() here and an
offset of 2, the first two rows of the results set are skipped. The
mysql_field_tell() function is used to
ascertain the index of the field being displayed within each loop of
the while statement. The
mysql_field_seek() function will return the
offset prior to invoking the function. If you change the
mysql_field_seek() call in the program to the
following, the old_offset variable would contain a
value of 0, the starting point for a row:
... MYSQL_FIELD_OFFSET old_offset = mysql_field_seek(result, offset); ...
You can use this for recording a point in a results set before moving the pointer. The program can later return to that point using the old offset.