-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
61 lines (52 loc) · 1.52 KB
/
main.cpp
File metadata and controls
61 lines (52 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <iostream>
#include "MySQL_Dao.h"
using namespace std;
int main()
{
MySQL_Dao mysql;
string sql;
//test add
/*
sql = "insert into te11st(content) values('test1'),('test2')";
long iRows = mysql.add(sql);
cout << "totally insert: " << iRows << " rows" << endl;*/
//test query list
/*
sql = "select * from test";
vector<MYSQL_ROW> vList = mysql.queryList(sql);
for(unsigned int i = 0; i < vList.size(); ++i){
MYSQL_ROW row = vList[i];
cout << "{ " << row[0] << ", " << row[1] << " }" << endl;
} */
//test query_row
//*
try{
sql = "select * from test where id=1";
MYSQL_ROW qRow = mysql.queryRow(sql);
cout << "{ " << qRow[0] << ", " << qRow[1] << " }" << endl;
} catch(string & e){
cout << "query_row fail, detail reason is: \n" << e << endl;
}
//*/
//test query_one
//*
try{
sql = "select content from test where id=1";
string content = mysql.queryOne(sql);
cout << content << endl;
} catch(string & e){
cout << "query_one fail, detail reason is: \n" << e << endl;
}
//*/
//test deleteItem
/*sql = "delete from test where id = 2";
long iRows = mysql.deleteItem(sql);
cout << "totally delete: " << iRows << " rows" << endl;*/
//test updateData
/*
sql = "update test set `content`='修改后...' where id=3";
long iRows = mysql.updateData(sql);
cout << "totally update: " << iRows << " rows" << endl;
*/
return 0;
}