2023-09-20 16:13:41 +08:00
|
|
|
#include <mysql/mysql.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
static MYSQL *conn_db = NULL;
|
|
|
|
|
|
|
|
// 连接
|
|
|
|
extern int connect_mysql(const char *host, int port, const char *user, const char *pwd, const char *db_name);
|
|
|
|
|
|
|
|
// 关闭
|
|
|
|
extern int close_mysql();
|
|
|
|
|
|
|
|
// 查询
|
|
|
|
extern int query(const char *sql, void (*callback)(MYSQL_ROW row, char (*columns)[30], int cols));
|
|
|
|
|
|
|
|
// 返回查询结果的行数
|
|
|
|
extern int result_rows(const char *sql);
|
|
|
|
|
|
|
|
// 插入
|
|
|
|
extern int insert(const char *sql, MYSQL_BIND *params);
|
|
|
|
|
2023-09-20 16:37:44 +08:00
|
|
|
extern int delete(const char *sql, MYSQL_BIND *params);
|
|
|
|
|
|
|
|
|
2023-09-20 16:13:41 +08:00
|
|
|
// 更新
|
|
|
|
extern int update(const char *sql, MYSQL_BIND *params);
|