Skip to content

Commit c5a0a37

Browse files
committed
Release 1.0.1
처음 연결 정보 입력 받는거 만듬 ID, PW, PORTNUMBER
1 parent dcc2872 commit c5a0a37

29 files changed

+42
-4
lines changed
8.5 KB
Binary file not shown.
0 Bytes
Binary file not shown.
Binary file not shown.

mysql_201320897/mysql_201320897/CSQuery.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@
22
#include "CSQuery.h"
33
#include <stdio.h>
44

5+
// 제작자 컴퓨터일 경우 주석 풀기
6+
//#define MYCOM
7+
8+
// 공용
59
#define DB_HOST "127.0.0.1"
10+
// 본인 컴퓨터용
611
#define DB_USER "root"
712
#define DB_PASS "root"
813
#define PORT 4306
914

15+
// 매크로
1016
#define QUOTE(...) #__VA_ARGS__
1117
#define QUERY_ERROR fprintf(stderr, "Mysql query error: %s\n", mysql_error(&conn))
1218
#define QUERY_BEHAVIOR(String) Query(this->m_pConnection, String) != 0
@@ -18,12 +24,26 @@
1824
bool CSQuery::connect() {
1925
// 초기화, 연결 수행
2026
mysql_init(m_pConnection);
21-
27+
#ifdef MYCOM
2228
m_pConnection = mysql_real_connect(&conn, DB_HOST,
2329
DB_USER, DB_PASS, NULL, PORT, (char *)NULL, 0);
2430

25-
printf("MySQL client version: %s\n============================\n", mysql_get_client_info());
31+
printf("MySQL client version: %s\n", mysql_get_client_info());
32+
printf("============================\n");
33+
#endif
34+
#ifndef MYCOM
35+
char ID[30], PW[30];
36+
int port_number = NULL;
37+
38+
printf("MySQL client version: %s\n", mysql_get_client_info());
39+
printf("USER ID : "); scanf_s("%s", ID, (unsigned int)sizeof(ID));
40+
printf("PASSWORD: "); scanf_s("%s", PW, (unsigned int)sizeof(PW));
41+
printf("PORT NUMBER: "); scanf_s("%4d", &port_number);
42+
printf("============================\n");
2643

44+
m_pConnection = mysql_real_connect(&conn, DB_HOST,
45+
ID, PW, NULL, (unsigned int)port_number, (char *)NULL, 0);
46+
#endif
2747
// 연결 확인
2848
if (m_pConnection)
2949
return true;
12 Bytes
Binary file not shown.
73 Bytes
Binary file not shown.
99 Bytes
Binary file not shown.
73 Bytes
Binary file not shown.
5.18 KB
Binary file not shown.
-15 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)