📄 mysqltest.cpp
字号:
#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <string.h>#include <mysql/mysql.h>#include "Mysqlport.h"int main(){ MYSQL_ROW rec; MYSQL_RES *res; res = NULL; int flag; printf("1111\n"); CSqlPort thsql; printf("2222\n"); flag = thsql.OpenSQL(); if(flag == 0) { res = thsql.SqlQuery("SELECT * FROM mytable;"); printf("3333\n"); if(res != NULL) { printf("***********************************************\n"); while(rec = mysql_fetch_row(res)) { printf("%s - %s \n",rec[0],rec[1]); } printf("***********************************************\n"); printf("4444\n"); mysql_free_result(res); printf("5555\n"); thsql.Begin(); printf("6666\n"); if(thsql.SqlCmd("INSERT INTO mytable (cc) VALUES ('44');") == 0) { printf("7777\n"); thsql.RollBack(); } else { printf("8888\n"); thsql.RollBack(); } } mysql_free_result(res); printf("***************\n"); thsql.Transcation("INSERT INTO mytable (cc) VALUES ('55');"); printf("9999\n"); thsql.CloseSQL(); } else { printf("*********ERROR*************\n"); thsql.CloseSQL(); } printf("end\n"); return EXIT_SUCCESS;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -