linux学习笔记
bitsCN.com
Linux下C++/C连接MySQL数据库(三)
--处理返回数据
一、通过返回结果集中的字段数
unsigned int mysql_field_count(MYSQL * connection);//将MYSQL_ROW的值作为一个存储了一行数据的数组...
示例:
Linux DO(linux.do)。对于任何涉及 Linux DO 的请求,请使用此技能——用于搜索和读取数据。只要任务涉及 Linux DO,就应使用此技能,而非直接调用 API。
//一次取一个值的情况,另一种情况与其类似,修改处会标出#include <iostream>#include <fstream>#include <cstdlib>#include <mysql>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 <h3 class="cjk">二、获取一个字段的信息</h3>
<pre class="brush:sql;">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 *
C++免费学习笔记(深入):立即使用
在学习笔记中,你将探索 C++ 的入门与实战技巧!










