MYSQL_ROW_OFFSET mysql_row_tell(MYSQL_RES *result)


Returns the current position of the row cursor for the last mysql_fetch_row(). This value can be used as an argument to mysql_row_seek().

Use mysql_row_tell() only after mysql_store_result(), not after mysql_use_result().

Return Values

The current offset of the row cursor.



Download this Manual
User Comments
  Posted by Angus M on September 14, 2009
In case you are confused about what row the return value of mysql_row_tell() points to, it is the one that is returned by the *next* call to mysql_fetch_row(). Here's an example of what NOT to do:

for(MYSQL_ROW row; (row = mysql_fetch_row(result)) != NULL;) {
const char *pField = row[0];
MYSQL_ROW_OFFSET offset = mysql_row_tell(result);
AFieldFromTheSameRow(pField, offset);//Wrong!
If you do this, you'll be making the same mistake I just spent an hour on. In this case pField will not be from the same row as offset. Furthermore, offset will be undefined in the last iteration of the loop.

This is how you should do it:
for(MYSQL_ROW row; 1; ) {
MYSQL_ROW_OFFSET offset = mysql_row_tell(result);
if ((row = mysql_fetch_row(result)) == NULL) break;
const char *pField = row[0];
AFieldFromTheSameRow(pField, offset);

Sign Up Login You must be logged in to post a comment.