C++如何正确获得mysql数据库查询结果
本人渣渣本科生,最近在用c++捣鼓mysql。我发现下面这几行代码不论sql语句怎么变返回结果的rowcount都是1025,这明显不对头,我的查询结果应该远大于这个数字...
本人渣渣本科生,最近在用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呢? 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励30(财富值+成长值)
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |