本人渣渣本科生,最近在用c++捣鼓mysql。我发现下面这几行代码不论sql语句怎么变返回结果的rowcount都是1025,这明显不对头,我的查询结果应该远大于这个数字。
MYSQL mydata;
MYSQL_RES *result = NULL;
result = mysql_store_result(&mydata);
int rowcount = mysql_num_rows(result);
如果查看MYSQL_RES的结构体
typedef struct st_mysql_res {
my_ulonglong row_count;
MYSQL_FIELD *fields;
MYSQL_DATA *data;
MYSQL_ROWS *data_cursor; unsigned long *lengths; /* column lengths of current row */
MYSQL *handle; /* for unbuffered reads */
const struct st_mysql_methods *methods;
MYSQL_ROW row; /* If unbuffered read */
MYSQL_ROW current_row; /* buffer to current row */
MEM_ROOT field_alloc;
unsigned int field_count, current_field;
my_bool eof; /* Used by mysql_fetch_row */
/* mysql_stmt_close() had to cancel this result */
my_bool unbuffered_fetch_cancelled;
void *extension;} MYSQL_RES;
明显row_count可以是很大的数字,所以这是为什么呢,怎么才能获得正确的row_count呢?
MYSQL mydata;
MYSQL_RES *result = NULL;
result = mysql_store_result(&mydata);
int rowcount = mysql_num_rows(result);
如果查看MYSQL_RES的结构体
typedef struct st_mysql_res {
my_ulonglong row_count;
MYSQL_FIELD *fields;
MYSQL_DATA *data;
MYSQL_ROWS *data_cursor; unsigned long *lengths; /* column lengths of current row */
MYSQL *handle; /* for unbuffered reads */
const struct st_mysql_methods *methods;
MYSQL_ROW row; /* If unbuffered read */
MYSQL_ROW current_row; /* buffer to current row */
MEM_ROOT field_alloc;
unsigned int field_count, current_field;
my_bool eof; /* Used by mysql_fetch_row */
/* mysql_stmt_close() had to cancel this result */
my_bool unbuffered_fetch_cancelled;
void *extension;} MYSQL_RES;
明显row_count可以是很大的数字,所以这是为什么呢,怎么才能获得正确的row_count呢?