MCPcopy Create free account
hub / github.com/acl-dev/acl / main

Function main

lib_acl_cpp/samples/mysql2/mysql.cpp:39–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37}
38
39int main(void)
40{
41 // WIN32 ����Ҫ���ô˺��������й� SOCKET �ij�ʼ��
42 acl::acl_cpp_init();
43
44 // ������������־�������Ļ
45 acl::log::stdout_open(true);
46
47 acl::string line;
48 acl::stdin_stream in;
49 acl::stdout_stream out;
50
51#if defined(_WIN32) || defined(_WIN64)
52 const char* libname = "libmysql.dll";
53#else
54 const char* libname = "libmysqlclient_r.so";
55#endif
56
57 acl::string path;
58
59 // ��Ϊ���ö�̬���صķ�ʽ��������ҪӦ�ø��� mysql �ͻ��˿����ڵ�·��
60 out.format("Enter %s load path: ", libname);
61 if (in.gets(line) && !line.empty())
62#if defined(_WIN32) || defined(_WIN64)
63 path.format("%s\\%s", line.c_str(), libname);
64#else
65 path.format("%s/%s", line.c_str(), libname);
66#endif
67 else
68 path = libname;
69
70 out.format("%s path: %s\r\n", libname, path.c_str());
71 // ���ö�̬����ص�ȫ·��
72 acl::db_handle::set_loadpath(path);
73
74 const char* dbaddr = "127.0.0.1:16811";
75 const char* dbname = "inc365_antispam_db";
76 const char* dbuser = "root", *dbpass = "";
77 acl::db_mysql db(dbaddr, dbname, dbuser, dbpass);
78
79
80 if (db.dbopen(NULL) == false)
81 {
82 printf("open db(%s) error\r\n", dbname);
83 getchar();
84 return 1;
85 }
86
87 printf("open db %s ok\r\n", dbname);
88
89 int ret = tbl_select(db);
90 if (ret >= 0)
91 {
92 printf(">>select ok\r\n");
93 }
94 else
95 printf(">>select error\r\n");
96

Callers

nothing calls this directly

Calls 9

acl_cpp_initFunction · 0.85
getsMethod · 0.80
mysql_libversionMethod · 0.80
mysql_client_infoMethod · 0.80
tbl_selectFunction · 0.70
formatMethod · 0.45
emptyMethod · 0.45
c_strMethod · 0.45
dbopenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…