linux下C api连接mysql,调用mysql_num_rows()得到的值总是1,明明结果集有4行啊,代码如下
my_ulonglong num;
if(num=mysql_num_rows(res_ptr)>0)
{
printf(“num of rows %llu\n”,num);
}
my_ulonglong num;
if(num=mysql_num_rows(res_ptr)>0)
{
printf(“num of rows %llu\n”,num);
}
解决方案:20分
res_ptr 是怎么样打开的?
The use of mysql_num_rows() depends on whether you use mysql_store_result() or mysql_use_result() to return the result set. If you use mysql_store_result(), mysql_num_rows() may be called immediately. If you use mysql_use_result(), mysql_num_rows() does not return the correct value until all the rows in the result set have been retrieved.
The use of mysql_num_rows() depends on whether you use mysql_store_result() or mysql_use_result() to return the result set. If you use mysql_store_result(), mysql_num_rows() may be called immediately. If you use mysql_use_result(), mysql_num_rows() does not return the correct value until all the rows in the result set have been retrieved.