本文整理汇总了C++中Database::Execute方法的典型用法代码示例。如果您正苦于以下问题:C++ Database::Execute方法的具体用法?C++ Database::Execute怎么用?C++ Database::Execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Database
的用法示例。
在下文中一共展示了Database::Execute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(){
cout << "-*-欢迎使用人力资源管理系统-*-\n" << endl;
cout << "输入show打印员工列表。\n更多帮助请输入help\n" << endl;
string com;//指令
Database DB;//数据库
while (true){
getline(cin,com);//获取输入命令
if (IgnoreLU(com,"exit") || IgnoreLU(com,"quit")){
DB.Save();
cout << "Bye" << endl;
break;
}
//StrSplit(com,sp,' ');
DB.Execute(com);
}
return 0;
}
示例2: _tmain
int _tmain(int argc, _TCHAR* argv[])
{
Log.loglevel = 999;
const char * username = "";
const char * password = "";
const char * dbname = "";
if(!sDatabase.Initialize("localhost", 3306, username, password, dbname, 1, 65536))
{
Log.Error("SQL", "could not connect");
return 1;
}
QueryResult * result = sDatabase.Query("SELECT guid, skills FROM characters");
do
{
char * skills = strdup(result->Fetch()[1].GetString());
if(strchr(skills, ',') != 0)
{
// need to convert
uint32 i = 0;
stringstream ss;
char * start = skills;
char * end;
for(;;)
{
// skill, skill+1, <add>0
end = strchr(start, ',');
if(!end)
break;
*end = '\0';
uint32 val = atoi(start);
start = end + 1;
ss << val << " ";
++i;
if(!(i % 2))
ss << "0 ";
}
sDatabase.Execute("UPDATE characters SET skills = '%s' WHERE guid = %u", ss.str().c_str(), result->Fetch()[0].GetUInt32());
Log.Debug("SQL", "UPDATE characters SET skills = '%s' WHERE guid = %u", ss.str().c_str(), result->Fetch()[0].GetUInt32());
}
} while(result->NextRow());
delete result;
sDatabase.Shutdown();
Log.Success("Program", "Exit normally");
return 0;
}