目录
一、思路
二、调用函数
三、例子
一、思路
要操作mysql数据库的话首先要连接已经建立的database,然后选择table,通过 mysql_store_result( ) 把 table 的内容选出来放到句柄,通过 mysql_num_fields( ) 统计 table 的字段,最后通过 mysql_fetch_field( ) 打印出字段
二、调用的函数如下:
mysql_init()
mysql_real_connect()
mysql_error()
mysql_query()
mysql_store_result()
mysql_num_fields()
mysql_fetch_field()
详细声明在 /usr/include/mariadb/mysql.h
MYSQL * (STDCALL *mysql_init)(MYSQL *mysql);
MYSQL * (STDCALL *mysql_real_connect)(MYSQL *mysql, const char *host, const char *user, const char *passwd, const char *db, unsigned int port, const char *unix_socket, unsigned long clientflag);
const char * (STDCALL *mysql_error)(MYSQL *mysql);
int (STDCALL *mysql_query)(MYSQL *mysql, const char *q);
MYSQL_RES * (STDCALL *mysql_store_result)(MYSQL *mysql);
unsigned int STDCALL mysql_num_fields(MYSQL_RES *res);
MYSQL_FIELD * (STDCALL *mysql_fetch_field)(MYSQL_RES *result);