Documentation Home
MySQL 5.6 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 31.1Mb
PDF (A4) - 31.1Mb
PDF (RPM) - 30.3Mb
EPUB - 7.7Mb
HTML Download (TGZ) - 7.5Mb
HTML Download (Zip) - 7.6Mb
HTML Download (RPM) - 6.5Mb
Eclipse Doc Plugin (TGZ) - 8.3Mb
Eclipse Doc Plugin (Zip) - 10.1Mb
Man Pages (TGZ) - 182.4Kb
Man Pages (Zip) - 293.8Kb
Info (Gzip) - 2.9Mb
Info (Zip) - 2.9Mb
Excerpts from this Manual mysql_row_tell()

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.



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.