c-router-emulator/router/db.h

26 lines
610 B
C

#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);
extern int delete(const char *sql, MYSQL_BIND *params);
// 更新
extern int update(const char *sql, MYSQL_BIND *params);