Documentation Home
MySQL 5.6 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 30.9Mb
PDF (A4) - 31.0Mb
PDF (RPM) - 30.1Mb
EPUB - 7.7Mb
HTML Download (TGZ) - 7.5Mb
HTML Download (Zip) - 7.5Mb
HTML Download (RPM) - 6.5Mb
Eclipse Doc Plugin (TGZ) - 8.2Mb
Eclipse Doc Plugin (Zip) - 10.0Mb
Man Pages (TGZ) - 181.3Kb
Man Pages (Zip) - 292.3Kb
Info (Gzip) - 2.9Mb
Info (Zip) - 2.9Mb
Excerpts from this Manual

23.8.7.60 mysql_row_tell()

MYSQL_ROW_OFFSET mysql_row_tell(MYSQL_RES *result)

Description

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.

Errors

None.


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.