Changeset 36082e8 in network-game for server


Ignore:
Timestamp:
Nov 27, 2012, 4:24:49 PM (12 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
59061f6
Parents:
8e540f4
Message:

Moved the database code to a new class

Location:
server
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • server/makefile

    r8e540f4 r36082e8  
    33FLAGS = $(LIB_FLAGS)
    44COMMON_PATH = ../common
    5 DEPENDENCIES = message.o Player.o
     5DEPENDENCIES = message.o Player.o DataAccess.o
    66
    77server : server.cpp $(DEPENDENCIES)
  • server/server.cpp

    r8e540f4 r36082e8  
    1414#include <arpa/inet.h>
    1515
    16 #include <mysql/mysql.h>
    17 
    1816#include <openssl/bio.h>
    1917#include <openssl/ssl.h>
     
    2119
    2220#include "Player.h"
     21#include "DataAccess.h"
    2322#include "../common/message.h"
    2423
     
    239238   }
    240239}
    241 
    242 int dbtest()
    243 {
    244         MYSQL *connection, mysql;
    245         MYSQL_RES *result;
    246         MYSQL_ROW row;
    247         int query_state;
    248 
    249         mysql_init(&mysql);
    250 
    251         connection = mysql_real_connect(&mysql,"localhost","pythonAdmin","pyMaster09*","pythondb",0,0,0);
    252 
    253         if (connection == NULL) {
    254                 cout << mysql_error(&mysql) << endl;
    255                 return 1;
    256         }else
    257                 cout << "Connection successful" << endl;
    258 
    259         query_state = mysql_query(connection, "SELECT * FROM users");
    260 
    261         if (query_state !=0) {
    262                 cout << mysql_error(connection) << endl;
    263                 return 1;
    264         }
    265 
    266         result = mysql_store_result(connection);
    267 
    268         while ( ( row = mysql_fetch_row(result)) != NULL ) {
    269                 cout << row[0] << ", " << row[1] << ", " << row[2] << endl;
    270         }
    271 
    272         mysql_free_result(result);
    273         mysql_close(connection);
    274 
    275         cout << "Test finished" << endl;
    276 
    277         return 0;
    278 }
Note: See TracChangeset for help on using the changeset viewer.