Documentation Home
MySQL 5.6 リファレンスマニュアル
Download this Manual
PDF (US Ltr) - 26.8Mb
PDF (A4) - 26.9Mb
HTML Download (TGZ) - 7.1Mb
HTML Download (Zip) - 7.2Mb mysql_row_tell()

MYSQL_ROW_OFFSET mysql_row_tell(MYSQL_RES *result)


最後の mysql_fetch_row() の行カーソルの現在の位置を返します。この値は、mysql_row_seek() への引数として使うことができます。

mysql_row_tell() は、mysql_use_result() のあとではなく、mysql_store_result() のあとにのみ使用します。





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.