建立单机版冒险岛中遇到的一个问题,求助。

发布时间:2024-05-18 15:48 发布:上海旅游网

问题描述:

怎么在MySql数据库中执行一条SQL语句:“alter table characters change exp exp int default 0;”
请问高手们这句话添加在数据库的什么地方?

以下是数据库的一些内容,我不懂这些。向高手们请教这句话加到什么地方?
#include "MySQLM.h"
#include <sstream>
#include <string>
using namespace std;

MYSQL MySQL::maple_db;

int MySQL::connectToMySQL(){
if(!mysql_real_connect(&maple_db, "localhost", "root", "123456", "maplestory", 3306, NULL, 0)){
printf(mysql_error(&maple_db));
return 0;
}
return 1;
}

int MySQL::getInt(char* table, int id, char* value){
MYSQL_RES *mres;
MYSQL_ROW mrow;
char query[255];
sprintf_s(query, 255, "select %s from %s where ID='%d';",value, table, id);
mysql_real_query(&maple_db, query, strlen(query));
mres = mysql_store_result(&MySQL::maple_db);
mrow = mysql_fetch_row(mres);
int ret = 0;
if(mysql_num_fields(mres) > 0){
string mr = string((char*)mrow[0]);
istringstream buffer(mr);
buffer >> ret;
}
return ret;
}

int MySQL::getCharactersIDs(int id, int IDs[3]){
MYSQL_RES *mres;
MYSQL_ROW mrow;
char query[255];
sprintf_s(query, 255, "select ID from characters where userid='%d';", id);
mysql_real_query(&maple_db, query, strlen(query));
mres = mysql_store_result(&MySQL::maple_db);
mrow = mysql_fetch_row(mres);
int ret = 0;
for(int i=0; i<mysql_num_rows(mres); i++){
string mr = string((char*)mrow[0]);
istringstream buffer(mr);
buffer >> IDs[i];
mrow = mysql_fetch_row(mres);
}
return (int)mysql_num_rows(mres);
}

int MySQL::isString(char* table, char* whr, char* wht){
MYSQL_RES *mres;
MYSQL_ROW mrow;
char query[255];
sprintf_s(query, 255, "select * from %s where %s='%s';",table, whr, wht);
mysql_real_query(&maple_db, query, strlen(query));
mres = mysql_store_result(&MySQL::maple_db);
mrow = mysql_fetch_row(mres);
if(mrow){
return 1;
}
return 0;
}

问题解答:

哇………………
那都是些什么啊???

我一点都看不懂

热点新闻