MySQL学习笔记_13_Linux下C++/C连接MySQL数据库(三)--处理返回数_MySQL
程序员文章站
2022-05-31 09:53:07
...
Linux学习笔记
bitsCN.com
Linux下C++/C连接MySQL数据库(三)
--处理返回数据
一、通过返回结果集中的字段数
unsigned int mysql_field_count(MYSQL * connection);//将MYSQL_ROW的值作为一个存储了一行数据的数组...
示例:
//一次取一个值的情况,另一种情况与其类似,修改处会标出#include#include #include #include using namespace std;void mysql_err_function(MYSQL * connection);void mysql_display(MYSQL * mysql,MYSQL_ROW sqlrow);int main(){ MYSQL * connection; connection = mysql_init(NULL); if (mysql_real_connect(connection,"localhost","root","123456","test",0,NULL,0)) { cout 二、获取一个字段的信息
1、MYSQL_FIELD *mysql_fetch_field(MYSQL_RES *result); 2、MYSQL_FIELD定义:typedef struct st_mysql_field{ char *name; /* Name of column */ char *table; /* Table of column if column was a field */ char *org_table; /* Org table name if table was an alias */ char *db; /* Database for table */ char *def; /* Default value (set by mysql_list_fields) */ unsigned long length; /* Width of column */ unsigned long max_length; /* Max width of selected set */ unsigned int flags; /* Div flags */ unsigned int decimals; /* Number of decimals in field */ enum enum_field_types type; /* Type of field. Se mysql_com.h for types *
上一篇: php 小乘法表实现代码_php技巧
下一篇: mysql触发器_MySQL